PlayerIO

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

Multiplayer Reference

Multiplayer  class documentationClass Message

Namespace: PlayerIO.GameLibrary
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 the server broadcasts to connected players indicating that a round is starting:

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 untill runtime.

In this example we send out the ConnectIds of all connected players to every new player that joins the room.

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

Message.Count

public uint
Count  [read-only]

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

Message.Type

public string
Type  [read-only]

The type of the current message

Message.Add

public void
Add (Int64 value)

Add a long to the message payload

Arguments

Int64 value
the value to add

Message.Add

public void
Add (UInt64 value)

Add a ulong to the message payload

Arguments

UInt64 value
the value to add

Message.Add

public void
Add (uint value)

Add a uint to the message payload

Arguments

uint value
the value to add

Message.Add

public void
Add (string value)

Add a string to the message payload

Arguments

string value
the value to add

Message.Add

public void
Add (int value)

Add a int to the message payload

Arguments

int value
the value to add

Message.Add

public void
Add (bool value)

Add a bool to the message payload

Arguments

bool value
the value to add

Message.Add

public void
Add (params object[] parameters)

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.

Message.Add

public void
Add (Double value)

Add a double to the message payload

Arguments

Double value
the value to add

Message.Add

public void
Add (Byte[] value)

Add a byte[] to the message payload

Arguments

Byte[] value
the value to add

Message.Add

public void
Add (Single value)

Add a float to the message payload

Arguments

Single value
the value to add

Message.Create

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

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.

Message.GetBoolean

public bool
GetBoolean (uint index)

Gets the bool at the given index

Arguments

uint index
The index to find the entry in

Message.GetByteArray

public Byte[]
GetByteArray (uint index)

Gets the byte[] at the given index

Arguments

uint index
The index to find the entry in

Message.GetDouble

public Double
GetDouble (uint index)

Gets the double at the given index

Arguments

uint index
The index to find the entry in

Message.GetFloat

public Single
GetFloat (uint index)

Gets the float at the given index

Arguments

uint index
The index to find the entry in

Message.GetInt

public int
GetInt (uint index)

Gets the int at the given index

Arguments

uint index
The index to find the entry in

Message.GetInteger

public int
GetInteger (uint index)

Gets the int at the given index

Arguments

uint index
The index to find the entry in

Message.GetLong

public Int64
GetLong (uint index)

Gets the long at the given index

Arguments

uint index
The index to find the entry in

Message.GetString

public string
GetString (uint index)

Gets the string at the given index

Arguments

uint index
The index to find the entry in

Message.GetUInt

public uint
GetUInt (uint index)

Gets the uint at the given index

Arguments

uint index
The index to find the entry in

Message.GetULong

public UInt64
GetULong (uint index)

Gets the ulong at the given index

Arguments

uint index
The index to find the entry in

Message.GetUnsignedInteger

public uint
GetUnsignedInteger (uint index)

Gets the uint at the given index

Arguments

uint index
The index to find the entry in

Message.GetUnsignedLong

public UInt64
GetUnsignedLong (uint index)

Gets the ulong at the given index

Arguments

uint index
The index to find the entry in