Library channels

Channels Library for sending data across server->server or client->client instances.

Functions

canSend() Returns whether the current instance is permitted to send a channel message.
listen( channelName, id, callback ) Adds a listener to the given channel.
listenPrivate( id, callback ) Adds a listener to your private channel.
remove( channelName, id ) Removes a listener.
removePrivate( id ) Removes a listener from your private channel.
send( channelName, ... ) Sends data to the given channel.
sendPrivate( ... ) Sends data to your private channel.


Functions

channels.canSend()
Returns whether the current instance is permitted to send a channel message. Channels are rate limited per tick and per instance.

Environment:

Shared

Return value:

    (boolean) True if you can immediately send a channel message, false otherwise.
channels.listen( channelName, id, callback )
Adds a listener to the given channel.

Environment:

Shared

Parameters:

  • (string) channelName: The name of the channel to listen to.
  • (Any) id: The ID of the callback, used later to remove it.
  • (function) callback: The function to run when this channel receives data. It is passed the entity calling, and data sent.
channels.listenPrivate( id, callback )
Adds a listener to your private channel.

Environment:

Shared

Parameters:

  • (Any) id: The ID of the callback, used later to remove it.
  • (function) callback: The function to run when this channel receives data. It is passed the entity calling, and data sent.
channels.remove( channelName, id )
Removes a listener.

Environment:

Shared

Parameters:

  • (string) channelName: The name of the channel the callback was listening to.
  • (Any) id: The ID value given to channels.listen().
channels.removePrivate( id )
Removes a listener from your private channel.

Environment:

Shared

Parameters:

  • (Any) id: The ID value given to channels.listenPrivate().
channels.send( channelName, ... )
Sends data to the given channel.

Environment:

Shared

Parameters:

  • (string) channelName: The channel to send data to.
  • (Any...) ...: The data to send to all listeners.
channels.sendPrivate( ... )
Sends data to your private channel.

Environment:

Shared

Parameters:

  • (Any...) ...: The data to send to all listeners.

Valid XHTML 1.0!