Skip to content

Client Notification Event

Event that fires on a client notification telling select users about entity's state change.

Event name

client-notification

Request

cn.emit('add-topics', 'client-notification')
cn.emit('remove-topics', 'client-notification')

Response

Response contains the following fields:

Field Type Description
entityId String ID of the entity that sent the notification.
entityType Integer Type of an entity. 1 is an Object, 2 is a Link.
stateId Integer ID of state, the specified entity transitioned into.
soundName String Name of the sound that plays on notification.
timestamp Integer Timestamp of the notification.

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', 'client-notification');

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

Response

{
    "entityId":"634023d414d3e37c5d8c865b",
    "entityType":1,
    "stateId":3,
    "soundName":"sound1",
    "timestamp":1667391064587
}