Model Changed Event

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

Event name

model-changed

Request

  • Subscribe

  • Unsubscribe

cn.emit('add-topics', 'model-changed')
cn.emit('remove-topics', 'model-changed')

Response

Response contains the following fields:

Field Type Description

id

String

ID of an entity that was created, deleted or modified.

changeType

Integer

Type of change that triggered this event. 1 if an entity was created, 2 — modified, 3 — removed.

entityType

Integer

Type of the entity that triggered this event. 1 is Object, 2 is Link.

user

Object

Information about the user who changed the model.

user.id

String

User’s ID.

user.login

String

User’s name.

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', 'model-changed');

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

Response

{
  "changeType":2,
  "id":"618ffac619e52c1cb9b09d64",
  "entityType":1,
  "user":{
    "id":"618fba5319e52c1cb9b09353",
    "login":"user.name"
  }
}