I started to write my own networking with lidgren. I am very far. My goal is to make later my own master server (lidgren has a example for that) and an auto matchmaking server which hosts server and closest again.
I am sick of Unity Networking (it's easy but limited), UNet and other things like photon. Photon is great but expensive for my plan.. and others do not have auto matchmaking... or they want to make it which still stays on server.
Well, I try to explain my idea and problem. I want to make an dynamic serialize method which I want to call:
void OnULGNetworkSerialize(NetIncomingMessage msg)
The client can send very different things like int, float, bool, vector3, vector2 and so on.
The messages goes to server.. and the server need to send back to other clients. Clients has same code but the server not. So how I can a solve this.
This part (server):
// Serializing
void OnULGNetworkSerialize(NetIncomingMessage msg)
{
int lenght = (int)msg.ReadByte();
for (int i = 1; i < lenght; i++)
{
// Read different types here
}
}
So if you look the code maybe you know what I want to try. The server or client have not always same message length and same types. So how could I still get the type and send to all clients?