WebSocket API Documentation (Event)
Connecting To The WebSocket
The following URL can be used to connect to the WebSocket event API:
Security
By default the Event API WebSocket will be restricted via HTTP Realm Auth and ACLs. The default credentials will be set to manager:manag3rpa55word, and the ACLs will be set up to only allow connections from localhost. You can also secure the connection further with SSL encryption. See Security for more information.
JSON
All messages sent to or from the Event API WebSocket must be in JSON format. Each event will contain a set of properties providing details of the event. Each event documentation page will specify the JSON representation, and properties, of the event.
Below is an example of an event that will be generated, when a user logs into the client interface:
"type": "userLogin",
"time": 1436889915953,
"coreServerId": "e5c01703-3c6d-429a-8712-66c826064e65",
"username": "mike",
"userId": "e7577c7b-5d58-46a5-a834-386f52401c19",
"userLoginId": "0c51236d-5f93-4379-8997-8a840a511497",
"port": 57042,
"ip": "127.0.0.1"
}
Base Event Properties
Every event will contain the following properties:
- type : Describes the type of event.
- time : Specifies the date/time the event was generated. Represented as a unix timestamp, in milliseconds.
- coreServerId : Specifies the id of the core server that fired the event.
Object IDs
Most events generated by the event API will contain UUIDs that can be used to identify objects the event relates to. Some events will reference multiple ids. These UUIDs are the same ids that are used to reference resources in the Live REST API, allowing collaboration between the Live REST API and the Event API.
Event Filtering
The Event API allows connections to specify which events they want to receive from the WebSocket, by specifying property filters.
The Filter Message
A message, with the following format, can be sent to the WebSocket, in order to set the current filters for the connection.
"type" : "filter",
"filters" : [
{"property" : "<property name>", "value" : "<filter value>"},
{"property" : "<property name>", "value" : "<filter value>"},
...
]
}
Where <property name> is the name of the property to filter on, and <filter value> is the property value to filter on. Multiple property filters can be specified.
Filter Message Response
When a filter message is sent, the WebSocket will respond with one of the following messages:
Success Message
Returned when the filter was properly applied.
"type": "success",
"time": 1436889163971,
"correlationId": null
}
Error Message
Returned when an error occurred while processing the filter message.
"type": "error",
"time": 1436889377766,
"error": "<error message>",
"correlationId": null
}
The error property will contain the details of the error that occurred.
Correlation ID
You can specify a correlation id in the filter message, in order to tie the filter message to the generated response message. The correlation id is optional, and can be any unique string. Randomly generated numbers, or UUIDs, are a good choice for correlation ids.
"type" : "filter",
"correlationId" : "123456",
"filters" : [
{"property" : "type" : "value" : "dial"}
]
}
The filter message above will respond with the following message:
"type": "success",
"time": 1436889163971,
"correlationId": "123456"
}
Wildcard
If you specify a value of "*" for a filter property value, the property filter will match on any value of the property. This can be used to specify that you wish to receive events that contain a specific property, but the value of the property does not matter.
Examples
If the following filter is provided, only userStatus events will be received. This filter can be used to detect when any user in the system changes their status.
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "userStatus"}
]
}
If the following filter is provided, only userLogin and userLogout events will be received, This filter can be used to detect when any user in the system logs in or out of the client.
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "userLogin"},
{"property" : "type" : "value" : "userLogout"}
]
}
If the following filter is provided, only userLogin and userLogout events, for a user with username mike, will be received. This filter can be used to detect when user mike logs in and out of the client.
"type" : "filter",
"filters" : [
{"property" : "type" : "value" : "userLogin"},
{"property" : "type" : "value" : "userLogout"},
{"property" : "username" : "value" : "mike"}
]
}
If the following filter is provided, only events that reference a user (i.e. contains the username property), will be received. This filter can be used to detect any changes relating to a specific user.
"type" : "filter",
"filters" : [
{"property" : "username" : "value" : "*"}
]
}
If the following filter is provided, the filter will be reset to default (all events will be received).
"type" : "filter",
"filters" : []
}
Events
The Event API will fire several events that are related to changes occurring in the system. All events that can be fired from the Event API are listed below. Details concerning each event, and their properties, can be found within the individual event documentation pages.