Standalone Networking
Note that implementing a custom networking solution is advanced, and for most use cases, utilizing an existing networking framework integration will work perfectly.
To implement custom networking using MPE4S, use the various send methods and SteamManager.Receive(ref byte[], out ulong, out int, out bool, int)
on the SteamManager
component:
SteamManager.SendSelf(byte[], int, int, bool, bool, bool)
SteamManager.SendSelf(IList<byte[]>, int[], int, bool, bool, bool)
SteamManager.SendOwner(byte[], int, int, bool, bool, bool)
SteamManager.SendOwner(IList<byte[]>, int[], int, bool, bool, bool)
SteamManager.Send(UInt64, byte[], int, int, bool, bool, bool)
SteamManager.Send(ulong, IList<byte[]>, int[], int, bool, bool, bool)
SteamManager.Send(byte[], int, int, bool, bool, bool, bool, ulong[], ISet<ulong>)
SteamManager.Send(IList<byte[]>, int[], int, bool, bool, bool, bool, ulong[], ISet<ulong>)
The above methods have the following properties for reliable and unreliable methods:
- Reliable messages are guaranteed to arrive exactly once to a user.
- Reliable messages sent over a channel are guaranteed to arrive in the same order they were sent. However, there is no guarantee for the order across multiple channels.
- For example if packet A is sent over channel
0
, packet B over channel0
, and packet C over channel1
to the same user in that order, packet A is guaranteed to arrive before packet B as they are both on the same channel, but packet C may arrive before either or both of them as it was sent on a different channel.
- For example if packet A is sent over channel
- Unreliable messages have no guarantees: they may arrive out of order, never at all, or potentially the same packet may arrive multiple times.
Sample
A basic sample is provided at Assets > KaijuSolutions > SteamMultiplayerEngine > Standalone > Samples > Multiplayer Engine for Steam - Standalone
. Note that this sample should not be considered a best practice, and is only meant to show the very basics of custom networking. In this sample, control your player using WASD or the arrow keys. If you deleted the sample or accidentally modified the sample scene, go to Tools > Kaiju Solutions > Multiplayer Engine for Steam > Dependencies > Standalone Sample
from the top menu, unless you have already removed all sample scripts from the project in which case you will need to reinstall MPE4S to get the sample back.
Resources
If you wish to learn more about implementing a custom networking solution, Valve has some great resources, and Gabriel Gambetta has great articles as well.
Testing
To test your game's multiplayer functionality locally, check out the testing documentation.