HTML5 (Javascript) Client Reference
Class multiplayer
Language: Javascript (HTML5)
The Multiplayer service. This class has method for listing, creating, and joining multiplayer rooms. Once a user has been sucessfully connected to a room, a connection object will be returned. This class is also used to override the development server setting when developing and testing multiplayer code against your local development server.
Example
Joining a multiplayer room and listening to all messages
Properties | ||||
---|---|---|---|---|
|
||||
|
||||
Methods | ||||
|
||||
|
||||
|
||||
|
multiplayer.developmentServer
|
If not null, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live multiplayer servers.
multiplayer.useSecureConnections
|
If set to true, the multiplayer connections will be encrypted using TLS/SSL. Be aware that this will cause a performance degradation by introducting secure connection negotiation latency when connecting.
multiplayer.createJoinRoom
|
Creates a multiplayer room (if it does not exist already) and joins it.
Arguments
roomId:string | |
The id of the room you wish to create/join. | |
roomType:string | |
The name of the room type you wish to run the room as. This value should match one of the [RoomType(...)] attributes of your uploaded code. A room type of 'bounce' is always available. | |
visible:bool | |
If the room doesn't exist: Should the room be visible when listing rooms with GetRooms upon creation? | |
roomData:object | |
If the room doesn't exist: The data to initialize the room with upon creation. | |
joinData:object | |
Data to send to the room with additional information about the join. | |
successCallback:function(connection) | |
Callback function that will be called with a connection to the room | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs |
multiplayer.createRoom
|
Create a multiplayer room on the Player.IO infrastructure.
Arguments
roomId:string | |
The id you wish to assign to your new room - You can use this to connect to the specific room later as long as it still exists. | |
roomType:string | |
The name of the room type you wish to run the room as. This value should match one of the [RoomType(...)] attributes of your uploaded code. A room type of 'bounce' is always available. | |
visible:bool | |
Should the room be visible when listing rooms with GetRooms or not? | |
roomData:object | |
The data to initialize the room with, this can be read with ListRooms and changed from the serverside. | |
successCallback:function(string) | |
Callback function that will be called with the newly created room id | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs |
multiplayer.joinRoom
|
Join a running multiplayer room.
Arguments
roomId:string | |
The id of the room you wish to connect to. | |
joinData:string | |
Data to send to the room with additional information about the join. | |
successCallback:function(connection) | |
Callback function that will be called with a connection to the room | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs |
multiplayer.listRooms
|
List the currently running multiplayer rooms.
Arguments
roomType:string | |
The type of room you wish to list. | |
searchCriteria:object | |
Only rooms with the same values in their roomdata will be returned. | |
resultLimit:int | |
The maximum amount of rooms you want to receive. Use 0 for 'as many as possible'. | |
resultOffset:int | |
The offset into the list you wish to start listing at. | |
successCallback:function(RoomInfo[]) | |
Callback function that will be called with a connection to the room | |
errorCallback:function(PlayerIOError) | |
Callback function that will be called if an error occurs |