/
Setting up SignalR communication for updates
Setting up SignalR communication for updates
We strongly recommend using the SignalR SDKs for robust and efficient client-server communication.
To establish a connection, utilize the HubConnectionBuilder
for negotiation as described below:
Negotiate endpoint
Utilize the following endpoint with the withUrl
method of HubConnectionBuilder
:
{baseUrl}/queues/{queueId}/positions/{positionId}?userId=${userId}
Parameters
Parameter | Type | Description |
---|---|---|
userId | guid/uuid | A random GUID/UUID. |
Establishing Connection
Initialize and build the hub connection as shown:
let hubConnectionBuilder = new signalR.HubConnectionBuilder()
.withUrl(url, options);
const hubConnection = hubConnectionBuilder.build();
hubConnection
.start()
.then(() => console.log('Queue service connection is established'))
.catch((err) => {
console.error(err);
throw err;
});
Subscription to Position Updates
Once the connection is established, subscribe to updates for the position-update
hub method:
const positionUpdateHubMethodName = 'position-update'
hubConnection.on(positionUpdateHubMethodName, (message: any) => {
const { position } = JSON.parse(message);
if (position) {
...
}
});
Message Structure
The message from the position-update
contains the following properties:
{
"position": {
"id": "5387920d-dfdd-4904-8a51-3f007effcffa",
"_ts": 1605613557,
"status": "notified",
"priority": 0,
"location": null,
"label": "A3",
"customerInfo": [
"Jörgen",
"Svensson",
"12345"
],
"type": "anonymous",
"queue": "c179a3a2-9fd7-4e12-96e7-19d9e957e094",
"createdAt": "2020-11-17T11:45:57.114Z",
"numberInTheQueue": 6
}
}
Related content
Update a position
Update a position
More like this
Create or update a ticket
Create or update a ticket
More like this
Webhooks integration
Webhooks integration
More like this