Subscription
API Subscription Websocket
Upon making this request, the server will upgrade to websocket connection. The websocket can then be used to manage subscriptions to MobiusFlow object COVs (change of values), resource COVs, service status changes and broadcast commands. Once the connection is initally established, the websocket server sends back a connected message, featuring the topic 'connected' as shown below. Once the upgrade is complete, all subsequent subcription communications are performed via websocket messages.
{
topic: 'connected',
payload: {}
}
Authorization
Following the inital http connect call, the now upgraded websocket connection expects a follow up authorization websocket message within 10 seconds. The authorization websocket message must feature the topic 'authorize' and a payload containing the API bearer token. An example message is shown below:
{
topic: 'authorize',
payload: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiIyYTZlMzQzNC1kZjI4LTQ1NDQtOTYzYS1mZTViMmQ1NTg0ZWIiLCJyb2xlcyI6MjU1LCJpYXQiOjE2NzE3MDgzMDksImV4cCI6MTY3MTcxMTkwOX0.ZiVb7nkGYkYB5Fl0KjE4aLLprJGBosXyTm12K_MeFnc'
}
On successful authorization, the websocket server will send back a confirmation message, containing the topic 'authorized' as shown below.
{
topic: 'authorized',
payload: {}
}
If no authorization message is received by the websockeet server within 10 seconds, the connection is dropped by the server.
Subscribing and Unsubscribing
Each subscription or unsubscription message must contain topic 'subscribe' or 'unsubscibe' respectively. Additonally, each message must feature a payload containing both the subscription type and subscription URI. Valid subscription types are denoted in the following table:
| Type | Description |
| object-cov | Object change of value events |
| resource-cov | Resource change of value events |
| service-status | Service status change of value events |
| broadcast-command | Broadcast command events |
Note, the URI field may contain MQTT style wildcards where appropriate.
An example subscibe message is shown below:
{
topic: 'subscribe',
payload: {
type: 'object-cov',
uri: '000001/020/0201/0001'
}
}
Following a successful subscription or unsubscripton message, the websocket server will echo the message back to the client, confirming the action has been made.
Event Responses
Each event response will feature a timestamp, topic and payload. The topic will be one of the valid event types as denoted in the above table. The payload will contain uri and value fields, the form of the latter varrying based on the type and nature of the event. An example response is shown below:
{
timestamp: '2023-10-01T12:00:00.000Z',
topic: 'resource-cov',
payload: {
uri: '000001/020/0201/0001',
value: 1
}
}
The values for each event type are as follows:
| Type | Value |
| object-cov | See 'Get live object' http call response within object controller |
| resource-cov | See 'Get live resource' http call response within object controller |
| service-status | See 'Get live object' http call response within object controller |
| broadcast-command | Varies depending on command type. Use get command profiles http call within profile controller for shape of responses. |
Switching Protocols
Bad Request
Unauthorized
Not Found
Request Timeout
Internal Server Error
Last updated
Was this helpful?

