PlayerIO

The fastest way to build online games without breaking a sweat.

Objective-C Client Reference

Multiplayer  class documentationClass PIOMultiplayer

Language: Objective-C

The Multiplayer Service

Here's how to create/join a room and send and receive messages:

Methods

 
- (void)
createJoinRoomWithRoomId:roomType:visible:roomData:joinData:successBlock:
Creates a multiplayer room (if it does not exist already) and joins it.
- (void)
createJoinRoomWithRoomId:roomType:visible:roomData:joinData:successBlock:errorBlock:
Creates a multiplayer room (if it does not exist already) and joins it.
- (void)
createRoomWithRoomId:roomType:visible:roomData:successBlock:
Create a multiplayer room on the Player.IO infrastructure.
- (void)
createRoomWithRoomId:roomType:visible:roomData:successBlock:errorBlock:
Create a multiplayer room on the Player.IO infrastructure.
- (PIOServerEndpoint*)
developmentServer
If set to non-nil value, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.
- (void)
joinRoomWithRoomId:joinData:successBlock:
Join a running multiplayer room.
- (void)
joinRoomWithRoomId:joinData:successBlock:errorBlock:
Join a running multiplayer room.
- (void)
listRoomsWithRoomType:searchCriteria:resultLimit:resultOffset:successBlock:
List the currently running multiplayer rooms.
- (void)
listRoomsWithRoomType:searchCriteria:resultLimit:resultOffset:successBlock:errorBlock:
List the currently running multiplayer rooms.
- (void)
setDevelopmentServer:
If set to non-nil value, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.

createJoinRoomWithRoomId:roomType:visible:roomData:joinData:successBlock:

Creates a multiplayer room (if it does not exist already) and joins it.

Arguments

NSString* roomId
The id of the room you wish to create/join.
NSString* roomType
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.
BOOL visible
If the room doesn't exist: Should the room be visible when listing rooms with GetRooms upon creation?
NSDictionary* roomData
If the room doesn't exist: The data to initialize the room with upon creation.
NSDictionary* joinData
Data to send to the room with additional information about the join.
void(^)(PIOConnection*connection) successBlock
A callback block that will be called with the established connection when the room has been joined

Throws

PlayerIOError

createJoinRoomWithRoomId:roomType:visible:roomData:joinData:successBlock:errorBlock:

Creates a multiplayer room (if it does not exist already) and joins it.

Arguments

NSString* roomId
The id of the room you wish to create/join.
NSString* roomType
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.
BOOL visible
If the room doesn't exist: Should the room be visible when listing rooms with GetRooms upon creation?
NSDictionary* roomData
If the room doesn't exist: The data to initialize the room with upon creation.
NSDictionary* joinData
Data to send to the room with additional information about the join.
void(^)(PIOConnection*connection) successBlock
A callback block that will be called with the established connection when the room has been joined
void(^)(PIOError*error) errorBlock
A callback block that will be called on error, with information about the error.

createRoomWithRoomId:roomType:visible:roomData:successBlock:

Create a multiplayer room on the Player.IO infrastructure.

Arguments

NSString* roomId
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.
NSString* roomType
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.
BOOL visible
Should the room be visible when listing rooms with GetRooms or not?
NSDictionary* roomData
The data to initialize the room with, this can be read with ListRooms and changed from the serverside.
void(^)(NSString*roomId) successBlock
A callback block that will be called with the final room id of the created room.

Throws

PlayerIOError

createRoomWithRoomId:roomType:visible:roomData:successBlock:errorBlock:

Create a multiplayer room on the Player.IO infrastructure.

Arguments

NSString* roomId
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.
NSString* roomType
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.
BOOL visible
Should the room be visible when listing rooms with GetRooms or not?
NSDictionary* roomData
The data to initialize the room with, this can be read with ListRooms and changed from the serverside.
void(^)(NSString*roomId) successBlock
A callback block that will be called with the final room id of the created room.
void(^)(PIOError*error) errorBlock
A callback block that will be called on error, with information about the error.

developmentServer

If set to non-nil value, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.

Return Value

PIOServerEndpoint*

joinRoomWithRoomId:joinData:successBlock:

Join a running multiplayer room.

Arguments

NSString* roomId
The id of the room you wish to connect to.
NSDictionary* joinData
Data to send to the room with additional information about the join.
void(^)(PIOConnection*connection) successBlock
A callback block that will be called with the established connection when the room has been joined

Throws

PlayerIOError

joinRoomWithRoomId:joinData:successBlock:errorBlock:

Join a running multiplayer room.

Arguments

NSString* roomId
The id of the room you wish to connect to.
NSDictionary* joinData
Data to send to the room with additional information about the join.
void(^)(PIOConnection*connection) successBlock
A callback block that will be called with the established connection when the room has been joined
void(^)(PIOError*error) errorBlock
A callback block that will be called on error, with information about the error.

listRoomsWithRoomType:searchCriteria:resultLimit:resultOffset:successBlock:

List the currently running multiplayer rooms.

Arguments

NSString* roomType
The type of room you wish to list.
NSDictionary* searchCriteria
Only rooms with the same values in their roomdata will be returned.
NSUInteger resultLimit
The maximum amount of rooms you want to receive. Use 0 for 'as many as possible'.
NSUInteger resultOffset
The offset into the list you wish to start listing at.
void(^)(NSArray*rooms) successBlock
A callback block that will be called with the list of rooms found

Throws

PlayerIOError, PlayerIOError

listRoomsWithRoomType:searchCriteria:resultLimit:resultOffset:successBlock:errorBlock:

List the currently running multiplayer rooms.

Arguments

NSString* roomType
The type of room you wish to list.
NSDictionary* searchCriteria
Only rooms with the same values in their roomdata will be returned.
NSUInteger resultLimit
The maximum amount of rooms you want to receive. Use 0 for 'as many as possible'.
NSUInteger resultOffset
The offset into the list you wish to start listing at.
void(^)(NSArray*rooms) successBlock
A callback block that will be called with the list of rooms found
void(^)(PIOError*error) errorBlock
A callback block that will be called on error, with information about the error.

setDevelopmentServer:

If set to non-nil value, rooms will be created on the development server at the address defined by the server endpoint, instead of using the live Player.IO servers.

Arguments

PIOServerEndpoint* developmentServer