Custom Server Event
This event fires when a server extension sends a custom server event.
The name and payload of this event depends on the information sent by an extension. We will use custom-server-event
in the examples below.
Request
-
Subscribe
-
Unsubscribe
cn.emit('add-topics', 'custom-server-event')
cn.emit('remove-topics', 'custom-server-event')
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', 'custom-server-event');
cn.on('job-added', msg => {
console.log(msg);
});