I am creating a chat program with a file share, and 2player game. Because of the many different types of things passing from the client and the server I am having issues parsing it out.
The game and chat programs use a String but the file share requires an object to be sent to the server then the clients have the option to download it from the server.
this is what I have right now, I am not quite sure where I need to start. I know what i will need to do to figure out the connect, game or message data(which are all string parsing) , but not sure how to manipulate the object.
anyone have any idea where I need to start?
//this is the method for the Client to receive incoming threads
private void ReceiveMessages()
{
// Receive the response from the server
srReceiver = new StreamReader(tcpServer.GetStream());
// If the first character of the response is 1, connection was successful
string ConResponse = srReceiver.ReadLine();
// If the first character is a 1, connection was successful
if (ConResponse[0] == '1')
{
// Update the form to tell it we are now connected
main.Invoke(new UpdateLogCallback(main.UpdateLog), new object[] { "Connected Successfully!" });
}
else // If the first character is not a 1 (probably a 0), the connection was unsuccessful
{
string Reason = "Not Connected: ";
// Extract the reason out of the response message. The reason starts at the 3rd character
Reason += ConResponse.Substring(2, ConResponse.Length - 2);
// Update the form with the reason why we couldn't connect
main.Invoke(new CloseConnectionCallback(main.CloseConnection), new object[] { Reason });
// Exit the method
return;
}
// While we are successfully connected, read incoming lines from the server
while (Connected)
{
try
{
// Show the messages in the log TextBox
main.Invoke(new UpdateLogCallback(main.UpdateLog), new object[] { srReceiver.ReadLine() });
}
catch { }
}
}