WebSocket Events

Real-time event reference for CDE CAD using Socket.io. Subscribe to calls, unit locations, panic alerts, BOLOs, and announcements.

Transport: CDE CAD uses Socket.io (v4) over WebSockets at wss://cdecad.com. All real-time events are scoped to community rooms using the naming pattern community-${communityId}. You must join a room before receiving any community-specific events.
Authentication: The Socket.io connection inherits the user's session cookie or you can pass a JWT token via the auth handshake option. Unauthenticated sockets can connect but will not receive privileged events.

Connection & Rooms

Connect to the CDE CAD Socket.io server and join a community room to start receiving events. Each community operates as an isolated room identified by its communityId.

Connecting with socket.io-client

import { io } from "socket.io-client";

const socket = io("wss://cdecad.com", {
  transports: ["websocket"],
  auth: {
    token: "your-jwt-token-here"
  }
});

socket.on("connect", () => {
  console.log("Connected:", socket.id);

  // Join a community room
  socket.emit("join-community", "64a1b2c3d4e5f6a7b8c9d0e1");
});

socket.on("connect_error", (err) => {
  console.error("Connection failed:", err.message);
});
join-community Client → Server

Joins the community-scoped room to begin receiving all events for that community.

FieldTypeDescription
communityIdstringThe ID of the community to join. Socket joins room community-${communityId}.
leave-community Client → Server

Leaves a community room. The client will stop receiving events for that community.

FieldTypeDescription
communityIdstringThe ID of the community to leave.
disconnect System

Fired when the socket disconnects. The server automatically removes the socket from all community rooms and cleans up any associated unit tracking data.

Call Events

These events are emitted by the server whenever a dispatch call is created, updated, or deleted. All call events are broadcast to the relevant community room.

new-911-call / new-call / newCall Server → Client

Emitted when a new call is created. All three event names fire with the same payload for backward compatibility.

FieldTypeDescription
_idstringUnique call identifier.
incidentNumberstringHuman-readable incident number (e.g. INC-2024-001542).
callTypestringType/nature of the call (e.g. "Traffic Stop", "Robbery").
locationstringStreet address or area description.
callerstringName of the caller or reporting party.
descriptionstringDetailed description of the incident.
prioritystringPriority level (e.g. "1", "2", "3").
timestampstringISO 8601 timestamp of call creation.
// Example payload
{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
  "incidentNumber": "INC-2024-001542",
  "callType": "Robbery",
  "location": "245 Vespucci Blvd",
  "caller": "John Doe",
  "description": "Armed robbery in progress at convenience store",
  "priority": "1",
  "timestamp": "2024-09-15T22:30:00.000Z"
}
callUpdated / call-updated Server → Client

Emitted when a call is updated via PUT or PATCH. The payload contains the full updated call object with all current fields.

call-deleted Server → Client

Emitted when a call is manually deleted or automatically purged after being open for 25+ minutes without activity.

FieldTypeDescription
callIdstringThe ID of the deleted call.
incidentNumberstringIncident number of the deleted call.
deletedBystringUsername or "system" if auto-deleted.
reasonstringReason for deletion (e.g. "Auto-delete: inactive 25+ min").
call-status-updated Server → Client

Emitted when a call's status changes (e.g. from "pending" to "active" or "closed").

FieldTypeDescription
callIdstringThe ID of the call.
incidentNumberstringIncident number.
newStatusstringThe new status value.
updatedBystringUsername of the dispatcher who made the change.
call-note-added Server → Client

Emitted when a note is added to a call. Scoped to the community room.

FieldTypeDescription
callIdstringThe ID of the call.
assignedUnitsarrayArray of unit IDs currently assigned to this call.
noteobjectThe note object containing the fields below.
note.textstringContent of the note.
note.addedBystringUsername who added the note.
note.addedAtstringISO 8601 timestamp.
// Example payload
{
  "callId": "64f1a2b3c4d5e6f7a8b9c0d1",
  "assignedUnits": ["unit-101", "unit-204"],
  "note": {
    "text": "Suspect fled on foot heading northbound",
    "addedBy": "Dispatcher_Smith",
    "addedAt": "2024-09-15T22:35:00.000Z"
  }
}

911 Specific Events

These events are specific to 911 emergency calls routed through the dispatch system, including map marker data and alert triggers.

new911Call Server → Client

Emitted via the dispatch system when a 911 call is created. Includes map marker data for the live dispatch map.

911Alert Server → Client

Lightweight alert event intended to trigger an audible notification on dispatch clients. Fired alongside new911Call.

FieldTypeDescription
callIdstringThe ID of the 911 call.
incidentNumberstringIncident number.
callTypestringNature of the 911 call.
locationstringReported location.
prioritystringPriority level.
Sound Trigger: Dispatch clients should play an alert sound when this event is received. The priority field can be used to vary the alert tone.
911CallUpdated Server → Client

Emitted when an active 911 call is updated. Contains the full updated 911 call object.

911CallClosed Server → Client

Emitted when a 911 call is closed/resolved.

FieldTypeDescription
callIdstringThe ID of the closed call.
incidentNumberstringIncident number.
dispositionstringFinal disposition of the call (e.g. "Arrest Made", "Cleared", "Unfounded").
unitsAssignedTo911 Server → Client

Emitted when units are assigned to a 911 call. Includes coordinate data for map rendering.

FieldTypeDescription
callIdstringThe ID of the 911 call.
incidentNumberstringIncident number.
unitsarrayArray of assigned unit objects.
coordinatesobjectLocation coordinates for map display.
coordinates.xnumberGTA world X coordinate.
coordinates.ynumberGTA world Y coordinate.
coordinates.znumberGTA world Z coordinate.
current911Calls Server → Client

Response event containing an array of all active 911 calls. Sent in reply to the request-911-calls client event.

// Payload: Array of active 911 call objects
[
  {
    "_id": "64f1a2b3c4d5e6f7a8b9c0d1",
    "incidentNumber": "INC-2024-001542",
    "callType": "Robbery",
    "location": "245 Vespucci Blvd",
    "status": "active",
    "priority": "1",
    "assignedUnits": [...],
    ...
  },
  ...
]

Unit & Location Events

Events for tracking unit positions, status changes, and online/offline state. Location data uses raw GTA V world coordinates.

unit-location-update Client → Server

Sent by a client to report the current position of a unit. The server broadcasts this to the community room as unit-location-updated.

FieldTypeDescription
communityIdstringCommunity ID.
unitIdstringUnique unit identifier.
unitNamestringDisplay name / call sign.
xnumberGTA world X coordinate.
ynumberGTA world Y coordinate.
znumberGTA world Z coordinate.
headingnumberHeading in degrees (0-360).
postalstringNearest postal code.
statusstringCurrent unit status.
timestampstringISO 8601 timestamp.
unit-location-updated Server → Client

Broadcast to the community room when a unit's location is updated. Contains the same data structure as unit-location-update.

unitLocationUpdate Server → Client

Emitted from the /api/dispatch/location-update REST endpoint. Contains raw GTA coordinates plus additional metadata.

FieldTypeDescription
unitIdstringUnique unit identifier.
unitNamestringDisplay name / call sign.
xnumberGTA world X coordinate.
ynumberGTA world Y coordinate.
znumberGTA world Z coordinate.
latnumberMapped latitude (for map rendering).
lngnumberMapped longitude (for map rendering).
headingnumberHeading in degrees.
jobstringUnit's job/department (e.g. "police", "ems").
statusstringCurrent unit status.
postalstringNearest postal code.
communityIdstringCommunity ID.
timestampstringISO 8601 timestamp.
lastUpdatestringISO 8601 timestamp of last known update.
// Example payload
{
  "unitId": "officer-42",
  "unitName": "1-Adam-12",
  "x": -1037.58,
  "y": -2738.21,
  "z": 13.76,
  "lat": 33.9425,
  "lng": -118.408,
  "heading": 245.3,
  "job": "police",
  "status": "10-8",
  "postal": "274",
  "communityId": "64a1b2c3d4e5f6a7b8c9d0e1",
  "timestamp": "2024-09-15T22:30:00.000Z",
  "lastUpdate": "2024-09-15T22:30:00.000Z"
}
unitLocationRemoved Server → Client

Emitted when a unit goes offline and should be removed from the live map.

FieldTypeDescription
unitIdstringUnit identifier to remove.
unitNamestringDisplay name of the unit.
unit-auto-offline Server → Client

Emitted when a unit is automatically set to offline due to 4 hours of inactivity (no location updates or status changes).

FieldTypeDescription
unitIdstringUnit identifier.
usernamestringUsername of the unit's operator.
callSignstringUnit call sign.
reasonstringAlways "4hr inactivity timeout".
timestampstringISO 8601 timestamp.
unit-status-update Client → Server

Sent by a client to change a unit's status. The server validates and broadcasts the change as unit-status-updated.

FieldTypeDescription
communityIdstringCommunity ID.
userIdstringUser/unit identifier.
statusstringNew status value (e.g. "10-8", "10-7", "10-6").
unit-status-updated Server → Client

Broadcast to the community room after a unit's status has been changed. Contains the updated status information.

userStatusUpdate Server → Client

Emitted when a user's on-duty status changes. Reflects whether a user is currently on duty and their active status code.

FieldTypeDescription
userIdstringUser identifier.
odIdstringOn-duty record identifier.
statusstringCurrent status code.
updatedAtstringISO 8601 timestamp of the update.
currentLocations Server → Client

Response event containing an object map of all currently tracked unit locations. Sent in reply to the request-locations client event. Keys are unit IDs, values are location objects.

// Payload: Object map of unit locations
{
  "officer-42": {
    "unitId": "officer-42",
    "unitName": "1-Adam-12",
    "x": -1037.58,
    "y": -2738.21,
    "z": 13.76,
    "heading": 245.3,
    "status": "10-8",
    "postal": "274",
    "timestamp": "2024-09-15T22:30:00.000Z"
  },
  "officer-77": {
    "unitId": "officer-77",
    "unitName": "2-Lincoln-30",
    ...
  }
}

Request Events

Client-to-server events used to request current state. The server responds with the corresponding data event.

request-locations Client → Server

Request all current unit locations for a community. The server responds with a currentLocations event.

FieldTypeDescription
communityIdstringCommunity ID to fetch locations for.
request-911-calls Client → Server

Request all active 911 calls for a community. The server responds with a current911Calls event.

FieldTypeDescription
communityIdstringCommunity ID to fetch 911 calls for.

Unit Assignment Events

Events related to assigning and removing units from active calls.

unitDetachedFromCall Client → Server Server → Client

Fired in both directions. A client can emit this to detach a unit from a call, and the server broadcasts it to the community room to notify all listeners.

FieldTypeDescription
callIdstringThe ID of the call.
odIdstringOn-duty record ID of the unit being detached.
odNamestringDisplay name of the unit.
reasonstringReason for detachment (e.g. "Reassigned", "End of shift").
unitRemovedFromCall Server → Client

Emitted by the server when a unit is removed from a call by a dispatcher. Includes information about remaining assigned units.

FieldTypeDescription
callIdstringThe ID of the call.
incidentNumberstringIncident number.
odIdstringOn-duty record ID of the removed unit.
odNamestringDisplay name of the removed unit.
reasonstringReason for removal.
remainingUnitsarrayArray of units still assigned to the call.
timestampstringISO 8601 timestamp.

Alert Events

High-priority events for panic buttons, BOLOs, and community announcements. These events require immediate client-side handling.

panic-button Server → Client

Emitted when an officer activates the panic button. Scoped to the community room. Clients should trigger an urgent audible and visual alert.

FieldTypeDescription
officerNamestringName of the officer in distress.
officerIdstringUnique officer identifier.
locationstringStreet name or area description.
postalstringNearest postal code.
coordinatesobjectExact position on the map.
coordinates.xnumberGTA world X coordinate.
coordinates.ynumberGTA world Y coordinate.
coordinates.znumberGTA world Z coordinate.
communityIdstringCommunity ID.
communityNamestringHuman-readable community name.
serverNamestringFiveM server name (if applicable).
timestampstringISO 8601 timestamp.
sourcestringOrigin of the panic: "fivem" (in-game) or "dispatch" (dashboard).
Critical Event: The panic button is a life-safety alert. Clients must handle this event with the highest priority -- display a prominent visual indicator and play a distinct alarm sound that differs from standard 911 alerts.
// Example payload
{
  "officerName": "Officer Martinez",
  "officerId": "officer-42",
  "location": "Strawberry Ave & Capital Blvd",
  "postal": "342",
  "coordinates": { "x": 243.7, "y": -1529.3, "z": 29.2 },
  "communityId": "64a1b2c3d4e5f6a7b8c9d0e1",
  "communityName": "San Andreas State RP",
  "serverName": "SASRP Main",
  "timestamp": "2024-09-15T22:45:00.000Z",
  "source": "fivem"
}
new-bolo Server → Client

Broadcast to the community room when a new BOLO (Be On the Lookout) is created. Contains the full BOLO object including suspect description, vehicle information, and issuing officer details.

new-announcement Server → Client

Emitted when a community announcement is published. Scoped to the community room.

FieldTypeDescription
_idstringAnnouncement ID.
titlestringAnnouncement title.
messagestringAnnouncement body text.
prioritystringPriority level: "info", "warning", or "urgent".
communityIdstringCommunity ID.
createdByNamestringDisplay name of the announcement author.
expiresAtstringISO 8601 timestamp when the announcement expires (nullable).
// Example payload
{
  "_id": "64f1a2b3c4d5e6f7a8b9c0d2",
  "title": "Server Maintenance Notice",
  "message": "The CAD system will undergo maintenance tonight at 02:00 UTC.",
  "priority": "warning",
  "communityId": "64a1b2c3d4e5f6a7b8c9d0e1",
  "createdByName": "Admin_Jones",
  "expiresAt": "2024-09-16T06:00:00.000Z"
}
announcement-removed Server → Client

Emitted when an announcement is removed or expired. Scoped to the community room. Clients should remove the announcement from any active displays.

FieldTypeDescription
idstringID of the removed announcement.

Complete JavaScript Client Example

A full working example using socket.io-client v4 that connects, joins a community, and listens for calls, unit updates, and panic alerts.

import { io } from "socket.io-client";

// ── Configuration ────────────────────────────────────────
const SOCKET_URL   = "wss://cdecad.com";
const JWT_TOKEN    = "your-jwt-token";
const COMMUNITY_ID = "64a1b2c3d4e5f6a7b8c9d0e1";

// ── Connect ──────────────────────────────────────────────
const socket = io(SOCKET_URL, {
  transports: ["websocket"],
  auth: { token: JWT_TOKEN },
  reconnection: true,
  reconnectionAttempts: 10,
  reconnectionDelay: 2000
});

// ── Connection Lifecycle ─────────────────────────────────
socket.on("connect", () => {
  console.log("[WS] Connected:", socket.id);

  // Join the community room
  socket.emit("join-community", COMMUNITY_ID);

  // Request current state
  socket.emit("request-locations", { communityId: COMMUNITY_ID });
  socket.emit("request-911-calls", { communityId: COMMUNITY_ID });
});

socket.on("disconnect", (reason) => {
  console.warn("[WS] Disconnected:", reason);
});

socket.on("connect_error", (err) => {
  console.error("[WS] Connection error:", err.message);
});

// ── Call Events ──────────────────────────────────────────
socket.on("new-911-call", (call) => {
  console.log("[CALL] New 911 call:", call.incidentNumber, call.callType);
  console.log("  Location:", call.location);
  console.log("  Priority:", call.priority);
  // Add to dispatch board UI...
});

socket.on("callUpdated", (call) => {
  console.log("[CALL] Updated:", call.incidentNumber);
  // Refresh call card in UI...
});

socket.on("call-deleted", (data) => {
  console.log("[CALL] Deleted:", data.incidentNumber, "by", data.deletedBy);
  // Remove from dispatch board...
});

socket.on("call-note-added", (data) => {
  console.log("[CALL] Note on", data.callId, ":", data.note.text);
  // Append note to call detail view...
});

// ── 911 Alerts ───────────────────────────────────────────
socket.on("911Alert", (alert) => {
  console.log("[911] ALERT:", alert.callType, "at", alert.location);
  playAlertSound(alert.priority);
  showNotification(alert);
});

socket.on("current911Calls", (calls) => {
  console.log("[911] Received", calls.length, "active calls");
  // Populate dispatch board with current calls...
});

// ── Unit Locations ───────────────────────────────────────
socket.on("unitLocationUpdate", (unit) => {
  console.log("[UNIT]", unit.unitName, "at", unit.x, unit.y, unit.z);
  // Update map marker...
});

socket.on("unitLocationRemoved", (data) => {
  console.log("[UNIT] Offline:", data.unitName);
  // Remove marker from map...
});

socket.on("unit-auto-offline", (data) => {
  console.log("[UNIT] Auto-offline:", data.callSign, "-", data.reason);
});

socket.on("currentLocations", (locations) => {
  console.log("[UNIT] Received", Object.keys(locations).length, "locations");
  // Initialize all map markers...
});

// ── Panic Button ─────────────────────────────────────────
socket.on("panic-button", (panic) => {
  console.error("[PANIC]", panic.officerName, "at", panic.location);
  console.error("  Postal:", panic.postal, "Source:", panic.source);

  // Trigger urgent UI alert
  showPanicOverlay(panic);
  playPanicAlarm();
  flashMapMarker(panic.coordinates);
});

// ── BOLOs & Announcements ────────────────────────────────
socket.on("new-bolo", (bolo) => {
  console.log("[BOLO] New BOLO received:", bolo);
  // Display BOLO notification...
});

socket.on("new-announcement", (announcement) => {
  console.log("[ANNOUNCE]", announcement.title, "-", announcement.priority);
  // Show announcement banner...
});

socket.on("announcement-removed", (data) => {
  console.log("[ANNOUNCE] Removed:", data.id);
  // Remove announcement banner...
});

// ── Cleanup on page unload ───────────────────────────────
window.addEventListener("beforeunload", () => {
  socket.emit("leave-community", COMMUNITY_ID);
  socket.disconnect();
});

// ── Helper functions (implement per your UI framework) ───
function playAlertSound(priority) { /* ... */ }
function playPanicAlarm() { /* ... */ }
function showNotification(alert) { /* ... */ }
function showPanicOverlay(panic) { /* ... */ }
function flashMapMarker(coords) { /* ... */ }
Tip: Install socket.io-client via npm: npm install socket.io-client@4. The library handles automatic reconnection, but you should re-emit join-community after each reconnect to rejoin the room.

Event Quick Reference

Event NameDirectionDescription
join-communityClient → ServerJoin a community room
leave-communityClient → ServerLeave a community room
disconnectSystemSocket disconnected, cleanup
new-911-call / new-call / newCallServer → ClientNew call created
callUpdated / call-updatedServer → ClientCall updated
call-deletedServer → ClientCall deleted or auto-purged
call-status-updatedServer → ClientCall status changed
call-note-addedServer → ClientNote added to call
new911CallServer → Client911 call with map markers
911AlertServer → Client911 alert (triggers sound)
911CallUpdatedServer → Client911 call updated
911CallClosedServer → Client911 call closed
unitsAssignedTo911Server → ClientUnits assigned to 911 call
current911CallsServer → ClientAll active 911 calls
unit-location-updateClient → ServerReport unit position
unit-location-updatedServer → ClientUnit position broadcast
unitLocationUpdateServer → ClientUnit position from REST API
unitLocationRemovedServer → ClientUnit went offline
unit-auto-offlineServer → ClientUnit auto-offline (4hr timeout)
unit-status-updateClient → ServerChange unit status
unit-status-updatedServer → ClientUnit status broadcast
userStatusUpdateServer → ClientUser on-duty status change
currentLocationsServer → ClientAll current unit locations
request-locationsClient → ServerRequest all unit locations
request-911-callsClient → ServerRequest active 911 calls
unitDetachedFromCallBothUnit detached from call
unitRemovedFromCallServer → ClientUnit removed from call
panic-buttonServer → ClientOfficer panic alert
new-boloServer → ClientNew BOLO created
new-announcementServer → ClientCommunity announcement
announcement-removedServer → ClientAnnouncement removed