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 |
||
public |
|
||
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 static |
|
||
public |
Removes a handler previously attached with addDisconnectHandler |
||
public |
Removes a message handler previously attached with addMessageHandler |
||
public |
Quick way to send messages to the server |
||
public |
Sends a message to the server |
Connection.connected
public |
|
Returns the connection's connected status
Connection.roomId
public |
|
Connection.addDisconnectHandler
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.
Arguments
handler:Function | |
Callback to execute if disconnected from the server. |
Connection.addMessageHandler
public |
|
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
public |
|
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
public |
|
Disconnects from the server
Connection.encode
public static |
|
Arguments
data:flash.utils:ByteArray | |
Connection.removeDisconnectHandler
public |
|
Removes a handler previously attached with addDisconnectHandler
Arguments
handler:Function | |
Callback we wish to remove the listener for. |
Connection.removeMessageHandler
public |
|
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 |
|
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
public |
|
Sends a message to the server
Arguments
m:playerio:Message | |