A multi-user game

kimosavi

Active member
Joined
Apr 9, 2009
Messages
34
Location
Chicago, IL
Programming Experience
3-5
Hi. I am developing a board game in VB Studio (not a web project).

I have some concerns regarding multi-users.

when one piece moves, I update the information in the server so the other clients (players) will know where that piece moved.

but how do I make the clients constantly check the server for updates?

do i use a timer that checks the server info every second?

as soon as player1 moves all other players should know it in their screens (real time) and the turn must me passed to player2.

is using a timer in the form a good approach? what other options do I have?

Thanks in advance!
 
How are you communicating with the server?

This is going to sound old, but in VB6 using the winsock control, you could establish a connection and then send two way traffic. When data is received, there is an event raised, So basically you could have a sub routine run everytime data was received, in your case when data was received, it would check the data and then call the required sub routines to move/update the game.

I'm not sure how to implement this in vb.net as i've not had the need yet. That kind of approach is the way I would tackle it though.
 
Thanks LeonR for the post.

I have a series of classes that connect to the server via DataAdapters and SQLCommands, these classes have different subs that execute updates and inserts and store them into public objects within the class. This is how i am talk to the DB right now, so there is no way with this approach that I will know of data changes, unless I go fetch them regulary.

I did a little search on the subject and now VB.NET uses the namespace "system.net.sockets" to manage network connections.

I am not familiar at all on how to use this or how can I implement an object that will constantly listen to data changes in the underlaying tables.

If you have any knowledge or informatin regarding this let me know.

I implemented a backgroundWorker so the update is done in the background. Works great but don't know if this is the correct way to implement this approach.
 
A timer would work. You could set a flag on the server, something as simple as Update=1 when there is a update and have your timer run some code that looks for the update flag. If it's set it then polls the rest of the data. Probably the easiest solution although not the prettiest.
 
Thanks Sprint for the Reply.

I have implemented something similar but without a flag. The information that retreives from the server is very small (10-15 rows, 10 columns) mostly Integer Type, there will be no lagging but a constant comm with the server.

I don't know how to set up the flag that you propose Update=1 on the server side... can you ilustrate please?
 
Oh, I just meant like a single row table with a single column that when a player goes his client updates it to a q or True and then that's the table/row/column the other clients look at...just a way to have the least amount of data traffic back and forth.
 
Sprint,

Thanks for your reply. I was hoping that this is what you meant.

I have a master table (session) that controls all the activity in the game , I could set a couple of fields that when data is updated in these area (like events, chats and character movements) then the fields are repopulated.

Sounds good, will give it a try. Thanks for your help!!!

if you find any other "less rudimentary" way of doing this let me know!
 
The other way of doing this would be to have a "Game Server" in the same way you have a "Database Server" (they could easily be the same machine).
You would write an app to run on the game server which does all the communication with the database and all the clients. The clients connect to the game server using sockets.
The app running on the game server know's who's turn it is and then just sends the "your turn" signal to that client. It almost negates the need for a database if you don't need to store information between games.
 
Back
Top