.NET Client Reference
Class 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 |
The number of data entries in the message, excluding the type. |
||
public string |
The type of the current message |
||
Methods | |||
public void |
Add a long to the message payload |
||
public void |
Add a ulong to the message payload |
||
public void |
Add a uint to the message payload |
||
public void |
Add a string to the message payload |
||
public void |
Add a int to the message payload |
||
public void |
Add a bool to the message payload |
||
public void |
Add multiple pieces of data to the message in one go. |
||
public void |
Add a double to the message payload |
||
public void |
Add a byte[] to the message payload |
||
public void |
Add a float to the message payload |
||
public Message |
Create a new Message |
||
public bool |
Gets the bool at the given index |
||
public Byte[] |
Gets the byte[] at the given index |
||
public Double |
Gets the double at the given index |
||
public Single |
Gets the float at the given index |
||
public int |
Gets the int at the given index |
||
public int |
Gets the int at the given index |
||
public Int64 |
Gets the long at the given index |
||
public string |
Gets the string at the given index |
||
public uint |
Gets the uint at the given index |
||
public UInt64 |
Gets the ulong at the given index |
||
public uint |
Gets the uint at the given index |
||
public UInt64 |
Gets the ulong at the given index |
Message.Count
public uint |
|
The number of data entries in the message, excluding the type.
Message.Type
public string |
|
The type of the current message
Message.Add
public void |
|
Add a long to the message payload
Arguments
Int64 | value |
the value to add |
Message.Add
public void |
|
Add a ulong to the message payload
Arguments
UInt64 | value |
the value to add |
Message.Add
public void |
|
Add a uint to the message payload
Arguments
uint | value |
the value to add |
Message.Add
public void |
|
Add a string to the message payload
Arguments
string | value |
the value to add |
Message.Add
public void |
|
Add a int to the message payload
Arguments
int | value |
the value to add |
Message.Add
public void |
|
Add a bool to the message payload
Arguments
bool | value |
the value to add |
Message.Add
public void |
|
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 a double to the message payload
Arguments
Double | value |
the value to add |
Message.Add
public void |
|
Add a byte[] to the message payload
Arguments
Byte[] | value |
the value to add |
Message.Add
public void |
|
Add a float to the message payload
Arguments
Single | value |
the value to add |
Message.Create
public Message |
|
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 |
|
Gets the bool at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetByteArray
public Byte[] |
|
Gets the byte[] at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetDouble
public Double |
|
Gets the double at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetFloat
public Single |
|
Gets the float at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetInt
public int |
|
Gets the int at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetInteger
public int |
|
Gets the int at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetLong
public Int64 |
|
Gets the long at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetString
public string |
|
Gets the string at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetUInt
public uint |
|
Gets the uint at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetULong
public UInt64 |
|
Gets the ulong at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetUnsignedInteger
public uint |
|
Gets the uint at the given index
Arguments
uint | index |
The index to find the entry in |
Message.GetUnsignedLong
public UInt64 |
|
Gets the ulong at the given index
Arguments
uint | index |
The index to find the entry in |