Push Events
Receive Sonoran CAD push events over the websocket API.
Last updated
Was this helpful?
Receive Sonoran CAD push events over the websocket API.
Last updated
Was this helpful?
Was this helpful?
pushEvent{
"key": "YOUR_API_KEY",
"type": "EVENT_UNIT_STATUS",
"data": {
"units": []
}
}const signalR = require("@microsoft/signalr");
const connection = new signalR.HubConnectionBuilder()
.withUrl("https://api.sonorancad.com/apiWsHub", {
transport: signalR.HttpTransportType.WebSockets,
skipNegotiation: true,
})
.withAutomaticReconnect()
.build();
connection.on("pushEvent", (payload) => {
try {
const event = typeof payload === "string" ? JSON.parse(payload) : payload;
console.log("Received push event:", event.type, event.data);
} catch (err) {
console.error("Failed to parse push event payload:", err.message);
}
});
await connection.start();
const auth = await connection.invoke(
"authenticate",
"yourCommunityId",
"yourApiKey",
1
);
if (!auth?.success) {
throw new Error(`Authentication failed: ${auth?.error || "unknown error"}`);
}