FiberLib is a library mod for sending and receiving packets from a Bopl Battle Mod. It is currently in a bare bones state and only includes necessary tools, but will soon include more utilities for making the developer experience simpler.
(This project still under development, so API can change)
- First make a global static variable for signature to send/recive packets
public static Signature signature;
- Register a packet recive handler
public class MyMod : BaseUnityPlugin
{
private void ReciveHandler(Packet packet, Connection connection, NetIdentity identity)
{
byte[] data = packet.data;
Console.WriteLine($"recived {data.Length} bytes");
}
private void Awake()
{
signature = PacketManager.RegisterPacketReciveHandler(ReciveHandler);
}
}
- Send Packet
public class MyMod : BaseUnityPlugin
{
private void OnGUI()
{
if (GUI.Button(new Rect(0, 50, 170f, 30f), "Send Packet"))
{
Console.WriteLine("Sending packet!");
Packet packet = new Packet(signature, Encoding.UTF8.GetBytes("Hello, World!"))
PacketManager.SendPacket(packet);
}
}
}
- Run setup.cmd and follow instructions
- Select build mode (Debug, Release, Thunderstore (only packages built dll))
- Done