WebSocket API Documentation (Event)

Last modified by michaely on 2021/09/10 23:34

Warning

This page is currently being written. Although the information below is probably accurate, it may not be complete or may have errors.

Information

The information on this page applies to iSymphony 3.2+.

Description

The WebSocket API provides realtime events pertaining to the current state of the iSymphony server. External applications can utilize this API to integrate with the iSymphony server, by reacting to events related to users, and call state. In conjunction with the CRM widget, this API can also be utilized to create custom widgets for the iSymphony client interface.

On this page:

The [toc] macro is a standalone macro and it cannot be used inline. Click on this message for details.
 

 

Connecting To The WebSocket

The following URL can be used to connect to the WebSocket event API:

ws://manager:manag3rpa55word@<hostname or ip of the iSymphony server>:58080/communication_manager/ws/event

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.

Information

When securing the API with SSL, the URL used to connect to the Event API WebSocket must use wss and port 55050, instead of ws and port 58080.

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.

Warning

The UUIDs do not persist across restarts of the iSymphony server. If the server is restarted, the objects will contain new UUIDs. Also, if an object is destroyed then re-added, even with the same configuration, the UUID that represents that object will be different from the original.

Event Filtering

The Event API allows connections to specify which events they want to receive from the WebSocket, by specifying property filters. 

Information

Filters specify which events to filter in, not filter out.

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.

 

Information

If an event does not contain a property specified in one of the filters, the event will not be received.

Information

Sending a filter message will clear any previously set filters.

Information

By default all events will be received, until a filter is 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.

Event List