category: Good pratices

What are Packets and requests?

Stormancer currently provides two types of communication between your clients and your server.

  • 'Send' methods send a single packet to a remote peer (client -> server or server->client(s)). These methods reprensent oneway, fire and forget messages, meaning you can't receive any responses. However, these are very bandwidth friendly and let you decide the reliability of your messages.

  • Requests (or Remote Procedure Calls (RPC)) open a twoway channel with your remote peer. It allows the peers to send one or several messages to each others as responses. This process is very heavy but gives you a chance to make your code simplier and more efficiant.

Requests are called with the 'RPC' methods. They will return a RX IObservable which provide a high level of flexibility and compatibility on .NET using the LINQ query language.

'RPCTask' will however return a Task, making it easier to use for calls that are expected to send a single or no response.

When do i use them ?

We recommend to use packets, fire and forget messages, when you don't expect any responses from the server or your client: Position updates in a real time gameplay, such as FPS, are the best exemple. Position updates are fired several time per seconds and are thus the most heavy network action to expect in most of your games. Sending single packet will send less data per packets, giving you more bandwidth to deal with.

RPC have to be used when you need a response from your peer. Operation progress, results and damages to name a few of what could be expecting one. Keep in mind that RPC are heavy and not to be fired several times per second, you should restrict them to occasional, mendatory and syncing actions.

Order: 0