PDA

View Full Version : Game in ships with using network.



Mariusz_1990
17th June 2013, 00:20
Hello All.
I need help with my project on Academy. I write game in ships with option , playing by network and also simple chat for users. I want send by network 3 things:
1. Simple strings from chat
2. Several variables type int for location ships (How pixels?)
3.And sending simple invitation to game (from one user to another user)

And now my question...

Can I send this all information in one function with created earlier one socket ? And next using one TcpServer to serve all requests?

I am thinking that also I can do several functions to send different informations and several servers to serve this functions.

Please about help in solve my problem. I don't know If my ideas are good.
And sorry for my language. I know little English :)

ChrisW67
17th June 2013, 00:39
You can use one server to receive and process messages of three different types by including a message type indicator (for example, invitation == 0, chat message == 1, position update == 2) at the start of the message. The server looks at the type indicator and handles the remainder of the message according to that type.

Mariusz_1990
17th June 2013, 21:33
Can you show me how this should look in code because I can't imagine