Event Streaming

Pipeline

How To Connect

  1. Get a fresh token from IDS (Core API token can be used)

  2. Set event streaming url

  3. Set SkipNegotiation to true

  4. Set TransportType to WebSockets

  5. Start the connection

  6. Bind on ReceiveMessage event

Url Samples

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

Code examples

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 token
options.SkipNegotiation = true; //// must set true
options.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 token
skipNegotiation: true, //// must set true
transport: 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 string
HubConnection connection = new HubConnectionBuilder()
.WithUrl(url, options =>
{
options.AccessTokenProvider = () => *** YOUR TOKEN *** //// IDS auth token
options.SkipNegotiation = true; //// must set true
options.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 string
const connection = new signalR.HubConnectionBuilder()
.withUrl(url, {
accessTokenFactory: () => *** YOUR TOKEN *** //// IDS auth token
skipNegotiation: true, //// must set true
transport: 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

App storePlay store