Player.IO

Build fun, powerful & scalable online and mobile games with the reliable backend your users expect

Sign Up | Sign In

ActionScript3 Reference

actionscript 3 Multiplayer class informationClass Multiplayer

Namespace: playerio
Language: ActionScript 3

Provides access to the Multiplayer services provided by Player.IO.

Properties

 
public
developmentServer :String

If defined the system will connect to a local development server instead of a live server.

Methods

 
public
createJoinRoom (roomId:String, roomType:String, visible:Boolean, roomData:Object, joinData:Object, callback:Function = null, errorHandler:Function = null):void

Creates or joins a room of the specified server type.

public
createRoom (roomId:String, roomType:String, visible:Boolean, roomData:Object, callback:Function = null, errorHandler:Function = null):void

Creates a room of the specified server type.

public
joinRoom (roomId:String, joinData:Object, callback:Function = null, errorHandler:Function = null):void

Joins an already existing room

public
listRooms (roomType:String, searchCriteria:Object, resultLimit:int, resultOffset:int, callback:Function = null, errorHandler:Function = null):void

List all room instances of a specific server type

developmentServer

If defined the system will connect to a local development server instead of a live server.

Return Value

Example

The following example connects to a development server running on localhost on port 8184

createJoinRoom

Creates or joins a room of the specified server type.

Arguments

String roomId
The id of the room, if set to null the room is assigned a random id
String roomType
The type of room we should start
Boolean visible
If the room should be returned when doing a listRooms request
Object roomData
Init data, this init data can be read on by server: {Name:"MyRoom", Level:3}
Object joinData
User join data, this join data can be read by the server: {Name:"Chris", Type:"Sniper"}
Function callback
Method executed when the createJoinRoom call executed successfully: function(connection:Connection):void{...}
Function errorHandler
Method executed if the createJoinRoom request failed: function(error:PlayerIOError):void{...}

createRoom

Creates a room of the specified server type.

Arguments

String roomId
The id of the room, if set to null the room is assigned a random id
String roomType
The type of room we should start
Boolean visible
If the room should be returned when doing a listRooms request
Object roomData
Init data, this init data can be read by server: {Name:"MyRoom", Level:3}
Function callback
Method executed when the createRoom call executed successfully, returns the id of the created room: function(roomId:String):void{...}
Function errorHandler
Method executed if the joinRoom request failed: function(error:PlayerIOError):void{...}

joinRoom

Joins an already existing room

Arguments

String roomId
The id of the room we wish to join
Object joinData
User join data, this join data can be read by the server: {Name:"Chris", Type:"Sniper"}
Function callback
Method executed when the joinRoom call executed successfully: function(connection:Connection):void{...}
Function errorHandler
Method executed if the joinRoom request failed: function(error:PlayerIOError):void{...}

listRooms

List all room instances of a specific server type

Arguments

String roomType
The type of room we should list
Object searchCriteria
Compares the properties of the parsed object to properties on the roomData object and returns only perfect matches. Passing the object {level:"3"} returns only rooms which have level defined as 3 on the roomData object. To use search criteria you must first define what properties are searchable under the Multiplayer menu option for your game.
int resultLimit
How many room instances should we load from the server
int resultOffset
At what offset should we list from
Function callback
Method executed when the listRooms call executed successfully: function(rooms:Array<RoomInfo>):void{...}
Function errorHandler
Method executed if the listRooms request failed: function(error:PlayerIOError):void{...}