Socket.IO

SAYMON uses Socket.IO v4.5.0 library to implement a Comet server.

Socket.IO enables low-latency, bidirectional, and event-based communication between a client and a SAYMON server.

Although Socket.IO uses WebSocket for transport when possible, it adds additional metadata to each packet. A WebSocket client won’t be able to connect to a Socket.IO server, and a Socket.IO client won’t be able to connect to a plain WebSocket server.

Connect to server

To connect to a Socket.IO server, use the socket.io-client package.

In this example, a Socket.IO client connects to a SAYMON server, subscribes to an Incidents event, and prints out every incident that occurs in the system.

const comet = require('socket.io-client');

// Comet settings
const COMET_CONNECT_TIMEOUT = 5000;
const sessionId = "..."
const conf = {
    cometHost: 'https://example.com',
    cometPort: '1234',
};

// Connect to a comet server
const url = `${conf.cometHost}` + (conf.cometPort ? `:${conf.cometPort}` : '');
const cn = comet.connect(url, {
    query: { forceNew: true, sessionId },
    timeout: COMET_CONNECT_TIMEOUT,
});

// Subscribe to an Incidents topic
cn.emit('add-topics', 'incidents');

// Handle server response
cn.on('incidents', msg => {
    console.log(msg);
});

SAYMON Events

SAYMON uses custom Socket.IO events to notify clients about updates of parts of the system in real-time.

Each event corresponds to an internal Kafka topic.

Event Description Kafka topic

bulk-finished

Fires when the bulk operation finishes.

SERVER_EVENT

custom-style-change

Fires when a user changes UI representation of an entity.

 — 

custom-server-event *

Fires when the server receives data from server extension.

* Event name is defined by the server extension.

SERVER_EVENT

client-notification

Event that fires when a client notification is received.

CLIENT_EVENT

error

Fires when there is an error connecting to the Comet server.

 — 

incidents

Fires when an incident occurs, changes or moves from active list to history.

INCIDENT

incident-count

Fires when the number of active incidents changes.

INCIDENT

job-added

This event fires when a job is created alongside the operation execution.

SERVER_EVENT

job-result-received

Event that fires when the job result was received.

SERVER_EVENT

mqtt

Subscribe to MQTT messages.

SERVER_EVENT

model-changed

Event that fires when a user adds, modifies or removes an Object or a Link.

MODEL_EVENT

stat

Event that fires, when a stat of the specified entity is updated.

ENTITY_STAT

state-change

Fires when the entity’s state changes.

ENTITY_STATE

snmp-trap

Subscribe to SNMP Traps.

SERVER_EVENT