Get a fresh token from IDS (Core API token can be used)
Set event streaming url
Set SkipNegotiation
to true
Set TransportType
to WebSockets
Start the connection
Bind on ReceiveMessage
event
To get all the incident messages
https://coreapi.my-clay.com/hub/incident?access_token={token}
To get all the entry messages
https://coreapi.my-clay.com/hub/entry?access_token={token}
To get a sites incident messages
https://coreapi.my-clay.com/hub/incident?collectionId={site_id}&access_token={token}
To get a sites entry messages
https://coreapi.my-clay.com/hub/entry?collectionId={site_id}&access_token={token}
Please change {token}
and {site_id}
with relevant data
Sample using SignalR .Net Client in C#:
Cppusing Microsoft.AspNetCore.SignalR.Client;var url = $"{streamingEndpointUrl}/hub/entry" or $"{streamingEndpointUrl}/hub/incident"HubConnection connection = new HubConnectionBuilder().WithUrl(url, options =>{options.AccessTokenProvider = () => *** YOUR TOKEN *** //// IDS auth tokenoptions.SkipNegotiation = true; //// must set trueoptions.Transports=HttpTransportType.WebSockets;}).Build();connection.On<string>("ReceiveMessage", message =>{//// incident or entry message});await connection.StartAsync();
Sample using SignalR Javascript Client:
const url = $"{streamingEndpointUrl}/hub/entry" or $"{streamingEndpointUrl}/hub/incident"const connection = new signalR.HubConnectionBuilder().withUrl(url, {accessTokenFactory: () => *** YOUR TOKEN *** //// IDS auth tokenskipNegotiation: true, //// must set truetransport: signalR.HttpTransportType.WebSockets,}).build();connection.on('ReceiveMessage', (message) =>{//// incident or entry message});await connection.start();
Instead of subscribing for all the messages, the client can subscribe to a certain collection’s messages by adding a query string parameter with collection id value
Sample for site-related messages in C#:
using Microsoft.AspNetCore.SignalR.Client;var url = $"{streamingEndpointUrl}/hub/entry" or $"{streamingEndpointUrl}/hub/incident";url=url + $"?collectionId={CID}"; //// specify collection id in query stringHubConnection connection = new HubConnectionBuilder().WithUrl(url, options =>{options.AccessTokenProvider = () => *** YOUR TOKEN *** //// IDS auth tokenoptions.SkipNegotiation = true; //// must set trueoptions.Transports=HttpTransportType.WebSockets;}).Build();connection.On<string>("ReceiveMessage", message =>{//// incident or entry message});await connection.StartAsync();
Sample for site-related messages in JavaScript:
var url = $"{streamingEndpointUrl}/hub/entry" or $"{streamingEndpointUrl}/hub/incident";url = url + $"?collectionId={CID}" //// specify collection id in query stringconst connection = new signalR.HubConnectionBuilder().withUrl(url, {accessTokenFactory: () => *** YOUR TOKEN *** //// IDS auth tokenskipNegotiation: true, //// must set truetransport: signalR.HttpTransportType.WebSockets,}).build();connection.on('ReceiveMessage', (message) =>{//// incident or entry message});await connection.start();
Event streaming endpoints are hosted in core api domain.Here is the list of endpoints:
Incident subscription:
Accept: https://coreapi-accept.my-clay.com/hub/incident
Production: https://coreapi.my-clay.com/hub/incident
Entry subscription:
Accept: https://coreapi-accept.my-clay.com/hub/entry
Production: https://coreapi.my-clay.com/hub/entry