PlayerIO

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

Objective-C Client Reference

Multiplayer  class documentationClass PIOMessage

Language: Objective-C

Represents a message sent between client and server.

A message consists of a string type, and a payload of zero or more typed parameters.

For example here we create a simple message that we send to the server indicating that this player is ready:

You can also build up messages as you go, if you don't know the exact payload until runtime.

In this example, imagine the player has multiple pieces and we send in the list of moves this player wants to do in a single turn.

Methods

 
- (void)
addBool:
Add a boolean value to the end of the message
- (void)
addBoolean:
Add a boolean value to the end of the message
- (void)
addData:
Add an NSData object to the end of the message
- (void)
addDouble:
Add a floating point (64bit) value to the end of the message
- (void)
addFloat:
Add a floating point (32bit) value to the end of the message
- (void)
addInt:
Add an integer value to the end of the message
- (void)
addInteger:
Add an integer value to the end of the message
- (void)
addLong:
Add a long (64bit) value to the end of the message
- (void)
addString:
Add a string value to the end of the message
- (void)
addUInt:
Add an unsigned integer value to the end of the message
- (void)
addUnsignedInteger:
Add an unsigned integer value to the end of the message
- (void)
addUnsignedLong:
Add an unsigned long (64bit) value to the end of the message
- (BOOL)
boolAtIndex:
Get the boolean value at the given index
- (BOOL)
booleanAtIndex:
Get the boolean value at the given index
- (NSUInteger)
count
Get the number of objects in this Message.
- (NSData*)
dataAtIndex:
Get the NSData value at the given index
- (double)
doubleAtIndex:
Get the double value at the given index
- (float)
floatAtIndex:
Get the float value at the given index
- (id)
initWithType:
Initialize the message with the given type.
- (int32_t)
intAtIndex:
Get the integer value at the given index
- (int32_t)
integerAtIndex:
Get the integer value at the given index
- (int64_t)
longAtIndex:
Get the long value (64bit) at the given index
+ (PIOMessage*)
messageWithType:
Create a new autoreleased message with the given type
- (id)
objectAtIndex:
Gets the object at the given index
- (NSString*)
stringAtIndex:
Get the NSString value at the given index
- (NSString*)
type
The type of the message.
- (PIOMessageEntryType)
typeAtIndex:
Gets the type of object at the given index
- (uint32_t)
unsignedIntegerAtIndex:
Get the unsigned integer value at the given index
- (uint64_t)
unsignedLongAtIndex:
Get the unsigned long (64bit) value at the given index

addBool:

Add a boolean value to the end of the message

Arguments

BOOL string

addBoolean:

Add a boolean value to the end of the message

Arguments

BOOL string

addData:

Add an NSData object to the end of the message

Arguments

NSData* string

addDouble:

Add a floating point (64bit) value to the end of the message

Arguments

double string

addFloat:

Add a floating point (32bit) value to the end of the message

Arguments

float string

addInt:

Add an integer value to the end of the message

Arguments

int32_t string

addInteger:

Add an integer value to the end of the message

Arguments

int32_t string

addLong:

Add a long (64bit) value to the end of the message

Arguments

int64_t string

addString:

Add a string value to the end of the message

Arguments

NSString* string

addUInt:

Add an unsigned integer value to the end of the message

Arguments

uint32_t string

addUnsignedInteger:

Add an unsigned integer value to the end of the message

Arguments

uint32_t string

addUnsignedLong:

Add an unsigned long (64bit) value to the end of the message

Arguments

uint64_t string

boolAtIndex:

Get the boolean value at the given index

Arguments

NSUInteger index

Return Value

BOOL

booleanAtIndex:

Get the boolean value at the given index

Arguments

NSUInteger index

Return Value

BOOL

count

Get the number of objects in this Message.

Return Value

NSUInteger

dataAtIndex:

Get the NSData value at the given index

Arguments

NSUInteger index

Return Value

NSData*

doubleAtIndex:

Get the double value at the given index

Arguments

NSUInteger index

Return Value

double

floatAtIndex:

Get the float value at the given index

Arguments

NSUInteger index

Return Value

float

initWithType:

Initialize the message with the given type.

Arguments

NSString* type

Return Value

id

intAtIndex:

Get the integer value at the given index

Arguments

NSUInteger index

Return Value

int32_t

integerAtIndex:

Get the integer value at the given index

Arguments

NSUInteger index

Return Value

int32_t

longAtIndex:

Get the long value (64bit) at the given index

Arguments

NSUInteger index

Return Value

int64_t

messageWithType:

Create a new autoreleased message with the given type

Arguments

NSString* type

Return Value

PIOMessage*

objectAtIndex:

Gets the object at the given index

Arguments

NSUInteger index

Return Value

id

stringAtIndex:

Get the NSString value at the given index

Arguments

NSUInteger index

Return Value

NSString*

type

The type of the message.

Return Value

NSString*

typeAtIndex:

Gets the type of object at the given index

Arguments

NSUInteger index

Return Value

PIOMessageEntryType

unsignedIntegerAtIndex:

Get the unsigned integer value at the given index

Arguments

NSUInteger index

Return Value

uint32_t

unsignedLongAtIndex:

Get the unsigned long (64bit) value at the given index

Arguments

NSUInteger index

Return Value

uint64_t