State Change Event

Event that fires when an entity’s State was changed.

Event name

state-change

Request

  • Subscribe

  • Unsubscribe

cn.emit('add-topics', 'state-change')
cn.emit('remove-topics', 'state-change')

Response

Response contains the following fields:

Field Type Description

id

String

ID of a changed entity.

state_id

String

ID of the entity’s new state.

type

Integer

Type of an entity, whose state was changed. 1 is object, 2 is link, 3 is flow.

Example

Request

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

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

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

cn.emit('add-topics', 'state-change');

cn.on('state-change', msg => {
      console.log(msg);
});

Response

{
  id: '5980512742d0d93ca8a3dbd4',
  state_id: 5,
  type: 1
}