
You are viewing a potentially older version of this package. View Latest Version

An API for plugin developers to implement networking between players.
This plugin is not meant for Rundown developers. It's an API for plugin developers
Everything is exposed by the NetworkingManager class. You need to create a marshallable struct that will be used to pass data between clients.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct ExampleEventData {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 101)]
public string ExampleText;
public uint ExampleNumber;
}
In order for Nidhogg to be able to send and receive events, they must be registered.
NetworkingManager.RegisterEvent<ExampleEventData>("Nidhogg_Example", (senderId, packet) =>
{
// This action will be invoked whenever the current user receives the event
Log.LogInfo($"Example received from {senderId}: {packet.ExampleText}. {packet.ExampleNumber}");
});
Now that we have registered our event, we can invoke it with the data we want other users to receive
NetworkingManager.InvokeEvent<ExampleEventData>("Nidhogg_Example", new ExampleEventData
{
ExampleText = "Hello world!",
ExampleNumber = 12345
});
The receiver will log Example received: Hello world!. 12345 to the console.
Due to how the internal protocol is made, every player must use the same version of the plugin.
This plugin is not meant for Rundown developers. It's an API for plugin developers