Channel based networking for Demeo mods.
Download the latest stable release's Py.LibNetwork-version+BuiltIn.zip
file
and extract it into your Demeo game folder.
You should have a folder structure that looks like this:
Demeo/
├─ DemeoMods/
│ ├─ Py.LibNetwork/
│ │ ├─ Py.LibNetwork.BuiltIn.dll
Other Loaders
Download the latest stable release's Py.LibNetwork-version+BepInEx.zip
file
and extract it into your Demeo game folder.
You should have a folder structure that looks like this:
Demeo/
├─ BepInEx/
│ ├─ plugins/
│ │ ├─ Py.LibNetwork.BepInEx.dll
Download the latest stable release's Py.LibNetwork-version+MelonLoader.zip
file
and extract it into your Demeo game folder.
You should have a folder structure that looks like this:
Demeo/
├─ Mods/
│ ├─ Py.LibNetwork.MelonLoader.dll
Add dependencies for ResolutionGames.Singleton.dll
(which can be found in Demeo's demeo_Data/Managed
folder)
and Py.LibNetwork.<loader>.dll
-
Add an event handler.
[!INFORMATION] Channel names can be anything, but it's recommended to include basic information such as mod name and a data version.
Since there's no mod version enforcement, you may need to apply data migrations.
SeePy.LibNetwork/RemoteModListHandler.cs
for a basic example.using Py.LibNetwork; const string ChannelName = "MyMod/MyChannel"; ModNetwork.Instance.OnMessage += (channel, data, sender) => { if(channel != ChannelName) return; using var dataStream = new MemoryStream(data); using (var reader = new BinaryReader(dataStream)) { var str = reader.ReadString(); DemeoLog.Log("MyMod", $"Player {sender.Value} says {str}!"); } };
-
Send a message to a specific player.
using var output = new MemoryStream(); using (var writer = new BinaryWriter(output)) { writer.Write("Hello World"); } // You can get playerData from vairous PlayerHub methods. ModNetwork.Instance.SendMessage(ChannelName, output.ToArray(), playerData.PlayerId);
-
Broadcast a message.
using var output = new MemoryStream(); using (var writer = new BinaryWriter(output)) { writer.Write("Hello World"); } ModNetwork.Instance.BroadcastMessage(ChannelName, output.ToArray());
As a basic example we provide RemoteModListHandler.cs,
but it can also be used to check which mods a remote player has installed.
RemoteModListHandler.RemoteModLists
is a static Dictionary
keyed by the player's PlayerId
, it'll only contain a key for a player
if we receive a mod list from them. It can contain an empty list if we receive a mod list with a newer protocol version than ours,
and we'll apply data migrations if it's an older known version.