WebSocket Events
Real-time event reference for CDE CAD using Socket.io. Subscribe to calls, unit locations, panic alerts, BOLOs, and announcements.
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.
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);
});
Joins the community-scoped room to begin receiving all events for that community.
| Field | Type | Description |
|---|---|---|
communityId | string | The ID of the community to join. Socket joins room community-${communityId}. |
Leaves a community room. The client will stop receiving events for that community.
| Field | Type | Description |
|---|---|---|
communityId | string | The ID of the community to leave. |
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.
Emitted when a new call is created. All three event names fire with the same payload for backward compatibility.
| Field | Type | Description |
|---|---|---|
_id | string | Unique call identifier. |
incidentNumber | string | Human-readable incident number (e.g. INC-2024-001542). |
callType | string | Type/nature of the call (e.g. "Traffic Stop", "Robbery"). |
location | string | Street address or area description. |
caller | string | Name of the caller or reporting party. |
description | string | Detailed description of the incident. |
priority | string | Priority level (e.g. "1", "2", "3"). |
timestamp | string | ISO 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"
}
Emitted when a call is updated via PUT or PATCH. The payload contains the full updated call object with all current fields.
Emitted when a call is manually deleted or automatically purged after being open for 25+ minutes without activity.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the deleted call. |
incidentNumber | string | Incident number of the deleted call. |
deletedBy | string | Username or "system" if auto-deleted. |
reason | string | Reason for deletion (e.g. "Auto-delete: inactive 25+ min"). |
Emitted when a call's status changes (e.g. from "pending" to "active" or "closed").
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the call. |
incidentNumber | string | Incident number. |
newStatus | string | The new status value. |
updatedBy | string | Username of the dispatcher who made the change. |
Emitted when a note is added to a call. Scoped to the community room.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the call. |
assignedUnits | array | Array of unit IDs currently assigned to this call. |
note | object | The note object containing the fields below. |
note.text | string | Content of the note. |
note.addedBy | string | Username who added the note. |
note.addedAt | string | ISO 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.
Emitted via the dispatch system when a 911 call is created. Includes map marker data for the live dispatch map.
Lightweight alert event intended to trigger an audible notification on dispatch clients. Fired alongside new911Call.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the 911 call. |
incidentNumber | string | Incident number. |
callType | string | Nature of the 911 call. |
location | string | Reported location. |
priority | string | Priority level. |
Emitted when an active 911 call is updated. Contains the full updated 911 call object.
Emitted when a 911 call is closed/resolved.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the closed call. |
incidentNumber | string | Incident number. |
disposition | string | Final disposition of the call (e.g. "Arrest Made", "Cleared", "Unfounded"). |
Emitted when units are assigned to a 911 call. Includes coordinate data for map rendering.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the 911 call. |
incidentNumber | string | Incident number. |
units | array | Array of assigned unit objects. |
coordinates | object | Location coordinates for map display. |
coordinates.x | number | GTA world X coordinate. |
coordinates.y | number | GTA world Y coordinate. |
coordinates.z | number | GTA world Z coordinate. |
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.
Sent by a client to report the current position of a unit. The server broadcasts this to the community room as unit-location-updated.
| Field | Type | Description |
|---|---|---|
communityId | string | Community ID. |
unitId | string | Unique unit identifier. |
unitName | string | Display name / call sign. |
x | number | GTA world X coordinate. |
y | number | GTA world Y coordinate. |
z | number | GTA world Z coordinate. |
heading | number | Heading in degrees (0-360). |
postal | string | Nearest postal code. |
status | string | Current unit status. |
timestamp | string | ISO 8601 timestamp. |
Broadcast to the community room when a unit's location is updated. Contains the same data structure as unit-location-update.
Emitted from the /api/dispatch/location-update REST endpoint. Contains raw GTA coordinates plus additional metadata.
| Field | Type | Description |
|---|---|---|
unitId | string | Unique unit identifier. |
unitName | string | Display name / call sign. |
x | number | GTA world X coordinate. |
y | number | GTA world Y coordinate. |
z | number | GTA world Z coordinate. |
lat | number | Mapped latitude (for map rendering). |
lng | number | Mapped longitude (for map rendering). |
heading | number | Heading in degrees. |
job | string | Unit's job/department (e.g. "police", "ems"). |
status | string | Current unit status. |
postal | string | Nearest postal code. |
communityId | string | Community ID. |
timestamp | string | ISO 8601 timestamp. |
lastUpdate | string | ISO 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"
}
Emitted when a unit goes offline and should be removed from the live map.
| Field | Type | Description |
|---|---|---|
unitId | string | Unit identifier to remove. |
unitName | string | Display name of the unit. |
Emitted when a unit is automatically set to offline due to 4 hours of inactivity (no location updates or status changes).
| Field | Type | Description |
|---|---|---|
unitId | string | Unit identifier. |
username | string | Username of the unit's operator. |
callSign | string | Unit call sign. |
reason | string | Always "4hr inactivity timeout". |
timestamp | string | ISO 8601 timestamp. |
Sent by a client to change a unit's status. The server validates and broadcasts the change as unit-status-updated.
| Field | Type | Description |
|---|---|---|
communityId | string | Community ID. |
userId | string | User/unit identifier. |
status | string | New status value (e.g. "10-8", "10-7", "10-6"). |
Broadcast to the community room after a unit's status has been changed. Contains the updated status information.
Emitted when a user's on-duty status changes. Reflects whether a user is currently on duty and their active status code.
| Field | Type | Description |
|---|---|---|
userId | string | User identifier. |
odId | string | On-duty record identifier. |
status | string | Current status code. |
updatedAt | string | ISO 8601 timestamp of the update. |
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 all current unit locations for a community. The server responds with a currentLocations event.
| Field | Type | Description |
|---|---|---|
communityId | string | Community ID to fetch locations for. |
Request all active 911 calls for a community. The server responds with a current911Calls event.
| Field | Type | Description |
|---|---|---|
communityId | string | Community ID to fetch 911 calls for. |
Unit Assignment Events
Events related to assigning and removing units from active calls.
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.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the call. |
odId | string | On-duty record ID of the unit being detached. |
odName | string | Display name of the unit. |
reason | string | Reason for detachment (e.g. "Reassigned", "End of shift"). |
Emitted by the server when a unit is removed from a call by a dispatcher. Includes information about remaining assigned units.
| Field | Type | Description |
|---|---|---|
callId | string | The ID of the call. |
incidentNumber | string | Incident number. |
odId | string | On-duty record ID of the removed unit. |
odName | string | Display name of the removed unit. |
reason | string | Reason for removal. |
remainingUnits | array | Array of units still assigned to the call. |
timestamp | string | ISO 8601 timestamp. |
Alert Events
High-priority events for panic buttons, BOLOs, and community announcements. These events require immediate client-side handling.
Emitted when an officer activates the panic button. Scoped to the community room. Clients should trigger an urgent audible and visual alert.
| Field | Type | Description |
|---|---|---|
officerName | string | Name of the officer in distress. |
officerId | string | Unique officer identifier. |
location | string | Street name or area description. |
postal | string | Nearest postal code. |
coordinates | object | Exact position on the map. |
coordinates.x | number | GTA world X coordinate. |
coordinates.y | number | GTA world Y coordinate. |
coordinates.z | number | GTA world Z coordinate. |
communityId | string | Community ID. |
communityName | string | Human-readable community name. |
serverName | string | FiveM server name (if applicable). |
timestamp | string | ISO 8601 timestamp. |
source | string | Origin of the panic: "fivem" (in-game) or "dispatch" (dashboard). |
// 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"
}
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.
Emitted when a community announcement is published. Scoped to the community room.
| Field | Type | Description |
|---|---|---|
_id | string | Announcement ID. |
title | string | Announcement title. |
message | string | Announcement body text. |
priority | string | Priority level: "info", "warning", or "urgent". |
communityId | string | Community ID. |
createdByName | string | Display name of the announcement author. |
expiresAt | string | ISO 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"
}
Emitted when an announcement is removed or expired. Scoped to the community room. Clients should remove the announcement from any active displays.
| Field | Type | Description |
|---|---|---|
id | string | ID 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) { /* ... */ }
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 Name | Direction | Description |
|---|---|---|
join-community | Client → Server | Join a community room |
leave-community | Client → Server | Leave a community room |
disconnect | System | Socket disconnected, cleanup |
new-911-call / new-call / newCall | Server → Client | New call created |
callUpdated / call-updated | Server → Client | Call updated |
call-deleted | Server → Client | Call deleted or auto-purged |
call-status-updated | Server → Client | Call status changed |
call-note-added | Server → Client | Note added to call |
new911Call | Server → Client | 911 call with map markers |
911Alert | Server → Client | 911 alert (triggers sound) |
911CallUpdated | Server → Client | 911 call updated |
911CallClosed | Server → Client | 911 call closed |
unitsAssignedTo911 | Server → Client | Units assigned to 911 call |
current911Calls | Server → Client | All active 911 calls |
unit-location-update | Client → Server | Report unit position |
unit-location-updated | Server → Client | Unit position broadcast |
unitLocationUpdate | Server → Client | Unit position from REST API |
unitLocationRemoved | Server → Client | Unit went offline |
unit-auto-offline | Server → Client | Unit auto-offline (4hr timeout) |
unit-status-update | Client → Server | Change unit status |
unit-status-updated | Server → Client | Unit status broadcast |
userStatusUpdate | Server → Client | User on-duty status change |
currentLocations | Server → Client | All current unit locations |
request-locations | Client → Server | Request all unit locations |
request-911-calls | Client → Server | Request active 911 calls |
unitDetachedFromCall | Both | Unit detached from call |
unitRemovedFromCall | Server → Client | Unit removed from call |
panic-button | Server → Client | Officer panic alert |
new-bolo | Server → Client | New BOLO created |
new-announcement | Server → Client | Community announcement |
announcement-removed | Server → Client | Announcement removed |