Skip to content

ConnectionManager API

Igal edited this page Apr 8, 2017 · 7 revisions

The ConnectionManager object keeps track of all of the open connections and channels for a specific WebSocket server endpoint.

broadcast(string channel, string message)

Sends the message to all of the subscribers of the Channel channel.

@param channel the id of the Channel

@param message the message to send

getChannel(string id):Channel

@returns the Channel with the given id, or null if no such Channel exist

getChannels():Map<String, Int>

@returns a java.util.Map where the keys are Channel IDs and the values is the number of subscribers.

log(string message)

Logs the message to the websocket log with level INFO.

subscribe(string channel, WebSocket connection):int

Subscribes the connection to the Channel identified by channel. The Channel is created if it does not exist.

@returns the number of subscribers for the Channel

unsubscribe(string channel, WebSocket connection):int

Unsubscribes the connection from the Channel identified by channel. If the Channel is empty it will be closed.

@returns the number of subscribers for the Channel

unsubscribeAll(WebSocket connection)

Unsubscribes the connection from all of the Channels to which it is subscribed.