0 of 0

File information

Last updated

Original upload

Created by

k0fe

Uploaded by

xxk0fe

Virus scan

Safe to use

Tags for this mod

About this mod

Plugin that allows networked messages to be sent between clients

Permissions and credits
Plugin that allows networked messages to be sent between clients. 

Requires: BepInEx

Usage:

Add dependency to your plugin: 
[BepInDependency("k0fe.NetworkManager", BepInDependency.DependencyFlags.HardDependency)]
[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)]
public class Plugin : BaseUnityPlugin

Create a network message with your fields:
public class MyMessage : INetworkMessage
{
public string Example;
}

Send network message from anywhere in the code:
NetworkRouter.Send(new MyMessage
{
Example = "Hello, World!"
});

Subscribe to network messages:
private void Awake()
{
NetworkRouter.Subscribe<MyMessage>(OnMessageReceived);
}

private void OnDestroy()
{
NetworkRouter.Unsubscribe<MyMessage>(OnMessageReceived);
}

private void OnMessageReceived(MyMessage message)
{
Logger.LogInfo($"Received message: {message.Example}");
}


Notes:
Currently messages are being sent to all clients. In the future I am planning to add functionality to send messages to specific players.