websocket

Websocket functions.

Example
var webSocketLib = require('/lib/xp/websocket');

Methods

(static) addToGroup(group, id)

Add an id to a socket group.

Parameters:
Name Type Description
group string

Group name.

id string

Socket id.

Example
webSocketLib.addToGroup('people', session.id);

(static) removeFromGroup(group, id)

Remove an id from a socket group.

Parameters:
Name Type Description
group string

Group name.

id string

Socket id.

Example
webSocketLib.removeFromGroup('people', session.id);

(static) send(id, message)

Send message directly to a socket id.

Parameters:
Name Type Description
id string

Socket id.

message string

Message as text.

Example
webSocketLib.send(session.id, 'You said - ' + message);

(static) sendToGroup(group, message)

Send message to all sockets in group.

Parameters:
Name Type Description
group string

Group name.

message string

Message as text.

Example
webSocketLib.sendToGroup('people', 'Notice this message!');