1. Notifications

Notifications

External Notifications can be used by a user to update a job or device, instantly when their status is changed and without making calls at regular intervals.

To receive external notifications you need the following:

WebSocket Client

This can be implemented in the MIS System by following the below sample

Install WebSocket4Net(open source websocket client implementation) nuget package:

PM> Install-Package WebSocket4Net

First a WebSocket connection is established between a user and the WebSocket server. URL: “ws://connect.aurelon.com:8080”

The Authorization is done using a MisKey which must be added by the user in WebSocket connection header fields with the key “MisKey” and the value of the MisKey.

//add MisKey in header
var customHeaderItems = new List<KeyValuePair<string, string>>();
customHeaderItems.Add(new KeyValuePair<string, string>(“MisKey”, miskey));

//create WebSocketClient
WebSocket webSocketClient = new WebSocket(“ws://connect.aurelon.com:8080”, “”, null, customHeaderItems, “”, “”, WebSocketVersion.None, null);

//open WebSocketClient connection
      webSocketClient.Open();

 

Register to Server events

The WebSocket Server will notify connected users with a JSON message when the status of a job or device has changed.

//attach to WebSocketClient events
webSocketClient.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(webSocketClient_Error);
webSocketClient.Opened += new EventHandler(webSocketClient_Opened);
webSocketClient.Closed += new EventHandler(webSocketClient_Closed);
webSocketClient.MessageReceived += new EventHandler<MessageReceivedEventArgs>(webSocketClient_MessageReceived);

 

JSON message ex:

– for Job: {“JobGUID”:”DD6BDDF6-74BA-4BD0-AC48-94A251A8ECA6″}

– for Device: {“DeviceGUID”:”8F1D80AB-06D5-43F8-A015-20347D9DE22C”}

 

Get updates

Once the notifications are received, you need to call the corresponding method to get the updates from the server.

In this step the user knows that an entity (job or device) has been modified and should make a REST call to External REST API (presented in details at point 1) get the latest values.

To connect to WebSocket Server (URL: “ws://connect.aurelon.com:8080”), the users must use a WebSocket Client.

 

MisKey

The MisKey value is generated in HUB Application in “Settings” -> “External API” page.

The user can regenerate the MisKey for an unlimited number of times using the “Generate” button. Using “Cancel” button the user will delete the MisKey stopping his access to notifications server.