socket
Socket Handling

Handling Socket Connections

The Kanboard application uses Socket.IO (opens in a new tab) to handle real-time events. The application is initialized with the following code:

var socket = io.connect(window.location.origin, {
  reconnection: true,
  reconnectionDelay: 1000,
  reconnectionDelayMax: 5000,
  reconnectionAttempts: 5,
});

Emitting events

When emitting events, the application uses the following format:

if (socket.connected) {
  socket.emit("event", { data: "data" });
}

Make sure to check if the socket is connected before emitting an event. Refer to the Socket.IO documentation (opens in a new tab) for more information.

Receiving events

When receiving events, the application uses the following format:

socket.on("event", function (data) {
  // do something
});

When the application is initialize the users enters the room host-[HOST-NAME]:user-[USER-ID] and the server sends the future events to this room.

The following events are used:

Timer related events

  • timer:start - Start the timer
  • timer:stop - Stop the timer
  • timer:reset - Reset the timer
  • timer:log - Log the time between two events
  • timer:attach - Attach the timer to a task
  • timer:detach - Detach the timer from a task

Task related events

  • task:created - Task created
  • task:completed - Task completed
  • task:reopened - Task reopened
  • task:updated - Task updated
  • task:deleted - Task deleted
  • task:reorder - Reorder tasks
  • task:view - View task (for displaying other task viewers)