ActionScript3 Reference
Class Connection
Namespace: playerio
Language: ActionScript 3
Allows the client to connect to the Multiplayer servers
Properties
|
| public |
Returns the connection's connected status
|
Methods
|
| public |
Listen to server disconnects. This method is only called if we are disconnected by the server. A call to connection.disconnect will not trigger this method.
|
| public |
Add listener for messages of a specified type
|
| public |
Creates a Message instance
|
| public |
Disconnects from the server
|
| public |
Removes a handler previously attached with addDisconnectHandler
|
| public |
Removes a message handler previously attached with addMessageHandler
|
| public |
| send |
(type:String, ... args):void |
Quick way to send messages to the server
|
| public |
Sends a message to the server
|
Connection.connected
Returns the connection's connected status
Connection.addDisconnectHandler
Listen to server disconnects. This method is only called if we are disconnected by the server. A call to connection.disconnect will not trigger this method.
Arguments
|
handler:Function |
|
Callback to execute if disconnected from the server. |
Connection.addMessageHandler
Add listener for messages of a specified type
Arguments
|
type:String |
|
String that defines what type to listen to. If sat to " the listener will listen to all message types |
|
handler:Function |
|
Callback method executed when a message of the type specified is recived: function(m:Message):void{...} or function(m:Message, messageValye1:Type, messageValye1:Typ, ... ):void{...} |
Example
Shows how to define a message listener
Example
Shows how to define a message listener with inline arguments
Connection.createMessage
Creates a Message instance
Arguments
|
type:String |
|
The type of the message |
|
... args |
|
Data entries we should add to the message when we create it |
Connection.disconnect
Disconnects from the server
Connection.removeDisconnectHandler
Removes a handler previously attached with addDisconnectHandler
Arguments
|
handler:Function |
|
Callback we wish to remove the listener for. |
Connection.removeMessageHandler
Removes a message handler previously attached with addMessageHandler
Arguments
|
type:String |
|
String that defines what type we wish to stop listening to |
|
handler:Function |
|
Callback we wish to remove the listener for |
Connection.send
| public |
| send |
(type:String, ... args):void |
|
Quick way to send messages to the server
Arguments
|
type:String |
|
The type of the message we want to send |
|
... args |
|
Data entries that should be added to the message |
Connection.sendMessage
Sends a message to the server
Arguments
|
message:playerio:Message |
|
Message to send to the server |