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 timertimer:stop
- Stop the timertimer:reset
- Reset the timertimer:log
- Log the time between two eventstimer:attach
- Attach the timer to a tasktimer:detach
- Detach the timer from a task
Task related events
task:created
- Task createdtask:completed
- Task completedtask:reopened
- Task reopenedtask:updated
- Task updatedtask:deleted
- Task deletedtask:reorder
- Reorder taskstask:view
- View task (for displaying other task viewers)