Setup SignalR communication about position.
We strongly recommend using SignalR SDKs.
For negotiation we use HubConnectionBuilder
. The following negotiate endpoint we provide in withUrl
method:
Negotiate endpoint
https://ombori-queue-dev.azure-api.net/api/organizations/xyz/queues/c179a3a2-9fd7-4e12-96e7-19d9e957e094/positions/5387920d-dfdd-4904-8a51-3f007effcffa?userId=${userId}
userId - random guid/uuid.
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; });
When connection is established you need to subscribe for specific hubMethodName. In our case it is position-update
:
const positionUpdateHubMethodName = 'position-update' hubConnection.on(positionUpdateHubMethodName, (message: any) => { const position = JSON.parse(message) as Position; if (position) { ... } });
The position contains the following properties:
{ "id": "5387920d-dfdd-4904-8a51-3f007effcffa", "_ts": 1605613557, "status": "notified", "priority": 0, "location": null, "label": "A3", "customerInfo": [ "Jörgen", "Svensson", "2200001910105" ], "type": "anonymous", "queue": "c179a3a2-9fd7-4e12-96e7-19d9e957e094", "createdAt": "2020-11-17T11:45:57.114Z", "numberInTheQueue": 6 }