Closed bberka closed 7 months ago
This already exists in the form of IMessageSerializable
:
public struct MyData : IMessageSerializable
{
public int ExampleInt;
public void Serialize(Message message)
{
message.AddInt(ExampleInt);
}
public void Deserialize(Message message)
{
ExampleInt = message.GetInt();
}
}
Then you can message.AddSerializable(new MyData() { ExampleInt = someValue });
and use message.GetSerializable()
on the other end.
Before i start im very new to these thing, i somewhat understand the logic behind multiplayer etc.
However i see in RiptideNetworking provides more low level management which is good for some cases
What i wanted to ask is if you wish to implement something like this for packet models
Instead of writing raw data inside handlers it would be (i think) better t omanage packet models like this because once things gets complicated it will be very hard to manage readers
This way all packet reader and writes are in same place
Serialization as you can see its raw binary and only important thing is you have to keep the same order (you probably know that)
I have similiar thing implemented on this https://github.com/bberka/NetTCP repository. You probably should check the dev/rework repo which is what i have been working on. You can check NetTcpPacketManager.cs to see how it is handled etc.
Since im not very much experienced its somewhat good but mine (probably) is not for game servers