Networked Game

Started by
3 comments, last by BeerNutts 11 years, 3 months ago

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.

/********************************************************************************\
/**********************He Who Dares, Wins**********************************\
/********************************************************************************\
Advertisement

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.

-[My Blog]-

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.

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!

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

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.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement