category: Getting Started

To send messages to remote peers, Stormancer provides methods hiding most of the complexity of the process. On Stormancer, messages are always sent in a scene to a route.

Here is the simpliest way to do that from the client:

peer.Send("route", mydata);

Where the peer object is an IPeerinstance (Scene on the client or Connection on the server).

To understand how to receive messages on the client or on the server, read [receiving messages][3].

The SDK provides a lot of flexibility regarding message handling, including serialization, reliability and priority options.

Furthermore, we also include by default [a remote procedure call][4]system built on top of the network stack that allow you to easily send request that expect one or several responses.

Choosing the reliability

When sending a message, you can choose between several reliability options available in the Raknet network engine. Let's look at them:

public enum PacketReliability
{
    UNRELIABLE = 0,
    UNRELIABLE_SEQUENCED = 1,
    RELIABLE = 2,
    RELIABLE_ORDERED = 3,
    RELIABLE_SEQUENCED = 4,
}

UNRELIABLE

Unreliable messages may arrive (or not), in the order you sent them or not. Stormancer doesn't provide any guarantee whatsoever for unreliable messages. However unreliable messages are very efficient networkwise.

UNRELIABLE_SEQUENCED

The messages are sent unreliably and may not arrive, and we discard messages that arrive out of order. It's the perfect option if older messages are obsolete (for player position updates for instance)

RELIABLE

The messages will be received reliably, but possibly out of order.

RELIABLE_ORDERED

This option is equivalent to reliable TCP networking: All the messages will arrive, in the order they were sent. It's also the less efficient option as the network engine will wait for an acknowledgment before sending new messages.

RELIABLE_SEQUENCED

When using this option, the messages are sent reliably, but if one of them arrive out of order it will be discareded. The effect is similar to the UNRELIABLE_SEQUENCED option, but with the guarantee that the last message in the sequence will be received.

Order: 6