Larios
❔ Are strings the best way for Server-Client UDP communication?
let's say for the sake of simplicity i only use this for RemoteClient, I would need to do a double serialization? I would have to serialize Message, but Message contains RemoteClient which has to be serialized aswell?
39 replies
❔ Are strings the best way for Server-Client UDP communication?
so I send a serialized Message object which has string orderString and RemoteClient remoteClient. Client deserializes Message, understands what to do from orderString and deserializes remoteClient?
39 replies
❔ Are strings the best way for Server-Client UDP communication?
I mean if i create a packet whic has a string, then at the end of the string the RemoteClient object, how does the receiving end know where the string ends and where the RemoteClient data starts
39 replies
❔ Are strings the best way for Server-Client UDP communication?
1) server sends UDP packet to client with string "alive?"
2) client receives UDP packet, reads the received string "alive?" and decides which method to use. Decides to use method which sends "yes" to server
3) server receives UDP packet, reads the received string "yes" and decides which method to use. Decides to use method which calculates latency and ticksToAdd
4) server creates RemoteClient remoteClient object, with int latency and int ticksToadd. Populates the fields with values calculated in step 3, serializes RemoteClient remoteClient and sends it to client.
5) client receives UDP packet. There is no string in the packet only a RemoteClient serialized object. How can the client know that it has to deserialize it? There is no string that tells the client what to do
39 replies
❔ Are strings the best way for Server-Client UDP communication?
Sometimes I need to send different data types, for example an int mixed together with a string. Like:
//Server
sendbuf = Encoding.ASCII.GetBytes($"Your Latency is:{answeringClient.latency},Add this amount of ticks:{ticksToAdd}");
//Client
string receivedString = Encoding.ASCII.GetString(receivedBytes, 0, receivedBytes.Length);
string[] splitString = receivedString.Split(",");
string latency = splitString[0].Substring(splitString[0].LastIndexOf(":") + 1);
string ticksToAdd = splitString[1].Substring(splitString[1].LastIndexOf(":") + 1);
logHandler.ConsoleLog($"Received latency = {latency} Ticks to add = {ticksToAdd}");
Eventually i'd love to pass more complex information, for example if I create an object server-side and I want the client to create it too
39 replies
❔ Are strings the best way for Server-Client UDP communication?
I did read a bit about serialization but I'm probably not understanding it.
Assuming I use xml serialization, Applying it to the example above, am I not just adding an extra step? I'd serialize the string before sending it, deserialize it while receiving, but I'd still have to compare the string in an if or switch statement to apply logic to it
39 replies