PlayerIO

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

Objective-C Client Reference

Multiplayer  class documentationClass PIOConnection

Language: Objective-C

A connetion to a multiplayer room.

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

Methods

 
- (void)
addDisconnectCallback:
Add a disconnect listener to this connection.
- (void)
addMessageCallback:
Add a message listener to this connection. The callback will be called on every message received by the connection.
- (void)
addMessageCallback:forType:
Add a message listener for a specific message type to this connection.
- (void)
disconnect
Disconnect from the game room
- (BOOL)
isConnected
Is the connection currently connected to a remote host?
- (void)
sendMessage:
Send a message to the room.

addDisconnectCallback:

Add a disconnect listener to this connection.

Arguments

void(^)(void) callback
The listener to add.

addMessageCallback:

Add a message listener to this connection. The callback will be called on every message received by the connection.

Arguments

void(^)(PIOMessage*message) callback
The listener to add.

addMessageCallback:forType:

Add a message listener for a specific message type to this connection.

Arguments

void(^)(PIOMessage*message) callback
The listener to add.
NSString* type
the specific type to limit the listener to

disconnect

Disconnect from the game room

isConnected

Is the connection currently connected to a remote host?

Return Value

BOOL

sendMessage:

Send a message to the room.

Arguments

PIOMessage* message
The message to send