❔ Are strings the best way for Server-Client UDP communication?
Hi I'm developing a server-client udp communication system using System.Net ( with classes like UdpClient, IPEndPoint etc. )
Right now my endpoints communicate through strings, example with a stupid request:
1) Server creates a string "Are you hungry?" converts it to bytes and sends it to client through UDP
2) Client receives the bytes, converts them to string, compares the string in a switch statement with a set of predefined strings.
3) Case "Are you hungry?" is met, logic runs and client creates a string "No I'm not hungry", converts it to bytes and sends it to Server through UDP
4) Server receives bytes, converts them to string, compares the string in a switch statement with a set of predefined strings
5) Case "No I'm not hungry" is met, logic runs and server sets the Client's "isHungry" variable to "false"
This all works properly ( for now eheh ), but before i keep going and make a huge project using this system, I just wanted to know if I'm doing things correctly.
My opinion currently is that the system is kinda hard to maintain because I'll end up having a huge amount of predefined strings to compare to.
Am i on the right track? Is there a much better way of doing this? My spider senses tell me that the way i'm doing it makes this way more complex than it should be
Right now my endpoints communicate through strings, example with a stupid request:
1) Server creates a string "Are you hungry?" converts it to bytes and sends it to client through UDP
2) Client receives the bytes, converts them to string, compares the string in a switch statement with a set of predefined strings.
3) Case "Are you hungry?" is met, logic runs and client creates a string "No I'm not hungry", converts it to bytes and sends it to Server through UDP
4) Server receives bytes, converts them to string, compares the string in a switch statement with a set of predefined strings
5) Case "No I'm not hungry" is met, logic runs and server sets the Client's "isHungry" variable to "false"
This all works properly ( for now eheh ), but before i keep going and make a huge project using this system, I just wanted to know if I'm doing things correctly.
My opinion currently is that the system is kinda hard to maintain because I'll end up having a huge amount of predefined strings to compare to.
Am i on the right track? Is there a much better way of doing this? My spider senses tell me that the way i'm doing it makes this way more complex than it should be