HTML5 (Javascript) Client Reference
Class connection
Language: Javascript (HTML5)
An instance of this class is returned after successfully joining a Multiplayer room. It encapsulates the active network connection between the user and the room, and has methods for sending and handling messages, as well as disconnecting fom the room. See the Multiplayer class for examples.
Properties | ||||
---|---|---|---|---|
|
||||
Methods | ||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
connection.connected
Indicates if the connection is still alive
connection.addDisconnectCallback
|
Add a disconnect callback that will be called when the connection is disconnected
Arguments
callback:function() | |
The callback to be called when a disconnect happens |
connection.addMessageCallback
|
Add a message callback for the given message type.
Arguments
type:string | |
The type of message to invoke the callback for. Use '*' to handle all message types. | |
callback:function(message) | |
The callback to be called when a message of the given type is received |
connection.createMessage
|
Create a message with arguments inline: connection.createMessage('invite', arg1, arg2...)
Arguments
type:string | |
The string type to give to the message. |
connection.disconnect
|
Disconnect from the multiplayer room
connection.removeDisconnectCallback
|
Remove an already registered disconnect callback
Arguments
callback:function | |
The callback to remove |
connection.removeMessageCallback
|
Remove an already registered message callback
Arguments
callback:function | |
The callback to remove |
connection.send
|
Send a message with arguments inline: connection.createMessage('invite', arg1, arg2...)
Arguments
type:string | |
The string type to give to the message. |
connection.sendMessage
|
Send a message
Arguments
message:message | |
The message to send. |