Sign in to follow this  
!Null

Networked Game

Recommended Posts

!Null    380

Okay so. I'm working on a project for University. It's an FPS.

 

I have made a basic server and the client and server can communicate via UDP (fairly simple stuff)

 

My question basically is, how should I deal with sending data from the client to the server and broadcasting the data of all players back to the client.

 

I've never really done anything like this before so it's all new to me.

 

Any advice would be appreciated.

Share this post


Link to post
Share on other sites
ghostbear_ac    160

I'd like to preface this with: I have very little networking experience, but I think I have a possible solution. 

  • When the user connects to the game, add their address info to a list or map. // This will allow you to send info to one person or iterate through them all. 
  • When a user sends info to the server and it determines what to do, send the response to everyone on the list or map

Let me know if that helps at all. 

Share this post


Link to post
Share on other sites

first and foremost, your networking should have several components each running in different threads.

you should have a thread at the server that processes unreliable inputs from the client. Each time the server receives an input from the client, the client is simulated

and the time stamp is recorded.

At specific time intervals, another server thread, copy information on client states and send to all clients. Each of the threads must be mutex protected due to data sharing.

 

Have another thread handle reliable message both from server and client.

Have another thread recieve messages from server and client and send them to an input queue, reliable message queue, game update queue depending on the packet header

designed by you. each queue is dequeued by the threads that will process them and each queue must be mutex protected due to data addition and removal.

This is just a rough idea of how to go about it.

Share this post


Link to post
Share on other sites
BeerNutts    4400

Please head over to the Networking Forum, and cehck out the FAQ.  There are tons of resources you can find there, and it's a better place for this question.

 

BTW, making a multiplayer FPS playable over the internet is HARD even for advanced programmer.  Good luck!

Share this post


Link to post
Share on other sites
BeerNutts    4400
first and foremost, your networking should have several components each running in different threads.

you should have a thread at the server that processes unreliable inputs from the client. Each time the server receives an input from the client, the client is simulated

and the time stamp is recorded.

At specific time intervals, another server thread, copy information on client states and send to all clients. Each of the threads must be mutex protected due to data sharing.

 

Have another thread handle reliable message both from server and client.

Have another thread recieve messages from server and client and send them to an input queue, reliable message queue, game update queue depending on the packet header

designed by you. each queue is dequeued by the threads that will process them and each queue must be mutex protected due to data addition and removal.

This is just a rough idea of how to go about it.

 

IMO, there's not real need for all these threads.  You can design a good networking system with threads, but unless you really know what you are doing, a simple loop with a select (or whatever networking API you use) can work just as good, or often better, as over-engineering can be an issue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this