Multi-User Live Updates
This article describes how to implement server-side support for the real-time updates module of DHTMLX Gantt.
Principle
DHTMLX Gantt provides the RemoteEvents helper to synchronize changes among multiple users in real time.
Key Workflow
- The
RemoteEventsclient opens a WebSocket connection when Gantt is initialized. - The User changes (the "create", "edit", or "delete" events) are sent to the server via
DataProcessorusing the REST API. - The server broadcasts updates to all connected clients via WebSocket after processing them.
- The
RemoteEventsclient receives the updates and applies them to Gantt, ensuring synchronization across users.
The design allows this backend module to support multiple DHTMLX widgets (e.g., Kanban, Gantt, Scheduler) within the same application. The shared format streamlines data synchronization without needing separate backends for each widget.
Front-End Integration
Initialize RemoteEvents and set up DataProcessor in the same section of code where Gantt data is loaded.
const AUTH_TOKEN = "token";
gantt.init("gantt_here");
gantt.parse("/data");
const dp = gantt.createDataProcessor({
url: "/data",
mode: "REST-JSON",
headers: {
"Remote-Token": AUTH_TOKEN,
},
});
const { RemoteEvents, remoteUpdates } = gantt.ext.liveUpdates;
const remoteEvents = new RemoteEvents("/api/v1", AUTH_TOKEN);
remoteEvents.on(remoteUpdates);