Event Subscription

The WebSocket interface in Viinex allows an integrating application to subscribe to events (e.g., events coming from IP camera detectors, built-in analytics systems, or analytics systems integrated via an external process; events coming via ModbusTCP, etc.) and use them in various scenarios to build an internal logic for video recording management or to build more complex logic using scripts.

The client application only needs to connect to the server, authorize, and subscribe to relevant events – after which it will receive these events in real-time via WebSocket. The server sends events to all clients subscribed to the object as soon as it receives events from the objects in Viinex.

An Example of Subscription to Events

Receive all events from all objects:

["subscribe", {}]

Receive all events from objects camera 1 and camera 2 (which may be ONVIF cameras or raw video sources):

["subscribe", {"origins": ["cam1","cam2"]}]

Receive events from motion detector and scene change detector at camera 1:

["subscribe", {"origins": ["cam1"],
              "topics": ["MotionAlarm", "GlobalSceneChange"]}]

Each of these events is transferred in a single WebSocket frame containing a JSON record:

"timestamp": TIMESTAMP,
"origin": {
"name": STRING, "type": STRING, ...
  • timestamp contains time of the event;
  • origin contains name and type of the source of the object that caused the event.
    Depending on the origin type of the event, such as an ONVIF event, there can be several additional values included in the event. For example, in the case of ONVIF events, the device may report a certain video detector ID or ID of the rule that caused a warning.