| Package | playerio |
| Interface | public interface Connection |
| Property | Defined By | ||
|---|---|---|---|
| connected : Boolean [read-only]
Returns the connection's connected status
| Connection | ||
| Method | Defined By | ||
|---|---|---|---|
addDisconnectHandler(handler:Function):void
Listen to server disconnects. | Connection | ||
addMessageHandler(type:String, handler:Function):void
Add listener for messages of a specified type
| Connection | ||
createMessage(type:String, ... args):Message
Creates a Message instance
| Connection | ||
disconnect():void
Disconnects from the server
| Connection | ||
removeDisconnectHandler(handler:Function):void
Removes a handler previously attached with addDisconnectHandler
| Connection | ||
removeMessageHandler(type:String, handler:Function):void
Removes a message handler previously attached with addMessageHandler
| Connection | ||
send(type:String, ... args):void
Quick way to send messages to the server
| Connection | ||
sendMessage(message:Message):void
Sends a message to the server
| Connection | ||
| connected | property |
connected:Boolean [read-only] Returns the connection's connected status
public function get connected():Boolean| addDisconnectHandler | () | method |
public function addDisconnectHandler(handler:Function):voidListen 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.
Parameters
handler:Function — Callback to execute if disconnected from the server.
|
| addMessageHandler | () | method |
public function addMessageHandler(type:String, handler:Function):voidAdd listener for messages of a specified type
Parameters
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{...}
|
connection.addMessageHandler("move", function(m:Message):void{
trace("Moved to", m.getInt(0), m.getInt(1))
})
connection.addMessageHandler("move", function(m:Message, x:int, y:int):void{
trace("Moved to", x, y)
})
| createMessage | () | method |
public function createMessage(type:String, ... args):MessageCreates a Message instance
Parameters
type:String — The type of the message
| |
... args — Data entries we should add to the message when we create it
|
Message — A Message instance
|
| disconnect | () | method |
public function disconnect():voidDisconnects from the server
| removeDisconnectHandler | () | method |
public function removeDisconnectHandler(handler:Function):voidRemoves a handler previously attached with addDisconnectHandler
Parameters
handler:Function — Callback we wish to remove the listener for.
|
| removeMessageHandler | () | method |
public function removeMessageHandler(type:String, handler:Function):voidRemoves a message handler previously attached with addMessageHandler
Parameters
type:String — String that defines what type we wish to stop listening to
| |
handler:Function — Callback we wish to remove the listener for
|
| send | () | method |
public function send(type:String, ... args):voidQuick way to send messages to the server
Parameters
type:String — The type of the message we want to send
| |
... args — Data entries that should be added to the message
|
| sendMessage | () | method |
public function sendMessage(message:Message):voidSends a message to the server
Parameters
message:Message — Message to send to the server
|