Skip to main content
deleted 1 characters in body
Source Link
Martin.
  • 429
  • 1
  • 5
  • 15

I'm currently creating a game which should be multiplayer (client-server-client), but I'm stuck.

I have been doing crazy things like building a text chain like

string networkMessage = userHash+" "+userX+" "+userY+" "+userRotation;

but it looks crazy and parsing is also bad

string[] pieces = networkMessage.Split(' ');
string userHash = pieces[0];
int userX = pieces[1];
int userY = pieces[2];
float userRotation = pieces[3];

So, what is the best way to pack my network commands & parse them on the second side?

Yeah, ehm.. I'm using TCP & StreamReader/StreamWriter

PS: yes, I know that giving client a possibility to set their coordinates is cheating risk and I'll change it later, so server will be more authorative)

I'm currently creating a game which should be multiplayer (client-server-client), but I'm stuck.

I have been doing crazy things like building a text chain like

string networkMessage = userHash+" "+userX+" "+userY+" "+userRotation;

but it looks crazy and parsing is also bad

string[] pieces = networkMessage.Split(' ');
string userHash = pieces[0];
int userX = pieces[1];
int userY = pieces[2];
float userRotation = pieces[3];

So, what is the best way to pack my network commands & parse them on the second side?

Yeah, ehm.. I'm using TCP & StreamReader/StreamWriter

PS: yes, I know that giving client a possibility to set their coordinates is cheating risk and I'll change it later, so server will be more authorative)

I'm currently creating a game which should be multiplayer (client-server-client), but I'm stuck.

I have been doing crazy things like building a text chain like

string networkMessage = userHash+" "+userX+" "+userY+" "+userRotation;

but it looks crazy and parsing is also bad

string[] pieces = networkMessage.Split(' ');
string userHash = pieces[0];
int userX = pieces[1];
int userY = pieces[2];
float userRotation = pieces[3];

So, what is the best way to pack my network commands & parse them on the second side?

Yeah, ehm.. I'm using TCP & StreamReader/StreamWriter

PS: yes, I know that giving client a possibility to set their coordinates is cheating risk and I'll change it later, so server will be more authorative

Tweeted twitter.com/#!/StackGameDev/status/162134737949949956
Source Link
Martin.
  • 429
  • 1
  • 5
  • 15

How to parse & "pack" network commands?

I'm currently creating a game which should be multiplayer (client-server-client), but I'm stuck.

I have been doing crazy things like building a text chain like

string networkMessage = userHash+" "+userX+" "+userY+" "+userRotation;

but it looks crazy and parsing is also bad

string[] pieces = networkMessage.Split(' ');
string userHash = pieces[0];
int userX = pieces[1];
int userY = pieces[2];
float userRotation = pieces[3];

So, what is the best way to pack my network commands & parse them on the second side?

Yeah, ehm.. I'm using TCP & StreamReader/StreamWriter

PS: yes, I know that giving client a possibility to set their coordinates is cheating risk and I'll change it later, so server will be more authorative)