Player.IO

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

Sign Up | Sign In

.NET Client Reference

Multiplayer  class documentationClass Message

Namespace: PlayerIOClient
Language: C# / .NET

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:

Usually, it's much easier to simply use the convenience methods:

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.

Properties

 
public uint
Count  [read-only]

The number of data entries in the message, excluding the type.

public string
Type  [read-only]

The type of the current message

Methods

 
public void
Add (Int64 value)

Add a long to the message payload

public void
Add (UInt64 value)

Add a ulong to the message payload

public void
Add (uint value)

Add a uint to the message payload

public void
Add (string value)

Add a string to the message payload

public void
Add (int value)

Add a int to the message payload

public void
Add (bool value)

Add a bool to the message payload

public void
Add (params object[] parameters)

Add multiple pieces of data to the message in one go.

public void
Add (Double value)

Add a double to the message payload

public void
Add (Byte[] value)

Add a byte[] to the message payload

public void
Add (Single value)

Add a float to the message payload

public Message
Create (string type, params object[] parameters)

Create a new Message

public bool
GetBoolean (uint index)

Gets the bool at the given index

public Byte[]
GetByteArray (uint index)

Gets the byte[] at the given index

public Double
GetDouble (uint index)

Gets the double at the given index

public Single
GetFloat (uint index)

Gets the float at the given index

public int
GetInt (uint index)

Gets the int at the given index

public int
GetInteger (uint index)

Gets the int at the given index

public Int64
GetLong (uint index)

Gets the long at the given index

public string
GetString (uint index)

Gets the string at the given index

public uint
GetUInt (uint index)

Gets the uint at the given index

public UInt64
GetULong (uint index)

Gets the ulong at the given index

public uint
GetUnsignedInteger (uint index)

Gets the uint at the given index

public UInt64
GetUnsignedLong (uint index)

Gets the ulong at the given index

Count

The number of data entries in the message, excluding the type.

Return Value

Type

The type of the current message

Return Value

Add

Add a long to the message payload

Arguments

Int64 value
the value to add

Add

Add a ulong to the message payload

Arguments

UInt64 value
the value to add

Add

Add a uint to the message payload

Arguments

uint value
the value to add

Add

Add a string to the message payload

Arguments

string value
the value to add

Add

Add a int to the message payload

Arguments

int value
the value to add

Add

Add a bool to the message payload

Arguments

bool value
the value to add

Add

Add multiple pieces of data to the message in one go.

Arguments

params object[] parameters
The data to add to the message

Example

Adding a string, a number and two boolean values to the message.

Add

Add a double to the message payload

Arguments

Double value
the value to add

Add

Add a byte[] to the message payload

Arguments

Byte[] value
the value to add

Add

Add a float to the message payload

Arguments

Single value
the value to add

Create

Create a new Message

Arguments

string type
The type of message to create.
params object[] parameters
A variable list of the data to add to the message.

Return Value

Message

GetBoolean

Gets the bool at the given index

Arguments

uint index
The index to find the entry in

Return Value

bool

GetByteArray

Gets the byte[] at the given index

Arguments

uint index
The index to find the entry in

Return Value

Byte[]

GetDouble

Gets the double at the given index

Arguments

uint index
The index to find the entry in

Return Value

Double

GetFloat

Gets the float at the given index

Arguments

uint index
The index to find the entry in

Return Value

Single

GetInt

Gets the int at the given index

Arguments

uint index
The index to find the entry in

Return Value

int

GetInteger

Gets the int at the given index

Arguments

uint index
The index to find the entry in

Return Value

int

GetLong

Gets the long at the given index

Arguments

uint index
The index to find the entry in

Return Value

Int64

GetString

Gets the string at the given index

Arguments

uint index
The index to find the entry in

Return Value

string

GetUInt

Gets the uint at the given index

Arguments

uint index
The index to find the entry in

Return Value

uint

GetULong

Gets the ulong at the given index

Arguments

uint index
The index to find the entry in

Return Value

UInt64

GetUnsignedInteger

Gets the uint at the given index

Arguments

uint index
The index to find the entry in

Return Value

uint

GetUnsignedLong

Gets the ulong at the given index

Arguments

uint index
The index to find the entry in

Return Value

UInt64