time to learn networking
by J Sears · 12/06/2006 (12:28 am) · 6 comments
Well I sat down and busted out enough scripting to have my card game work pretty well all on one machine, there were a couple small things to add but I saw those parts being very different in networking mode so no point in wasting my time on them yet. So currently the game is set up to be able to play up to 6 players, high card for dealer on start, shuffle and deal out the cards each hand (didn't add the player making his big yet, very simple to do but wanted to wait for network) players play their cards in turn order high card/trump card/special card wins that trick then they lead off that goes till all cards are gone, game compares each players hand score to their bid score and updates their overall score and then shuffles and deals again and it's all working all the card rules are working and the board clearing is working well. So now I need to learn how to get this to network the way I want
The unfortunate part is I want to do something I haven't found and tgb references on. For the most part it seems the networking part of TGB is very under documented. I understand real time networking isn't possible but that near real time is without any code changes (due to that one little demo game someone put out). So that means my idea should work but I don't know how to start it yet.
Here is my dream that I hope to make happen. When the player launches the game it connects to the master server (later on when I figure out how to make AI play this card game good there will be an option for single player) and upon connecting to the master server it loads up a screen of a chat room and enters the person in that chat. So of course the person can chat there then probably on the side of that there will be a window with tables (in the MSN zone style games I believe) where people can sit down at a table and when enough people sit that game launches so the screen changes to in that game and they start playing.
I haven't been able to find any good guides on doing much of any of that, so I will try to learn it over the next few days and try to get it going somehow. In the meantime I may start working on some of my awful graphics skills to set up some guis to give an idea of how it should look and if they're too ugly find someone who is willing to spend a little time making good ones.
my basic thought flow so far seems like most of this networking shouldn't be toooo bad
-auto connect to masterserver on load
- on connect place person's name in box that lists people there
- bottom of chat box has a text field box for person to type in when they hit enter or click send it sends it
to master server and master server updates everyone's chat box
- person clicks on one of the table's and sends a message to server saying they took that spot
- server checks to make sure spot is still open and is so puts a marker there, sends update on that
window to all connected
- when given table reaches set amount (first person to sit down would specify 3-6 players) server sends
message to all those machines updates image on the games window to everyone else as in progress
Now what I don't know at all yet is how to set each one of those games as a seperate game on the master server, hopefully it would be as easy as an array but have to learn more to know. So it all seems possible just have to figure it out.
The unfortunate part is I want to do something I haven't found and tgb references on. For the most part it seems the networking part of TGB is very under documented. I understand real time networking isn't possible but that near real time is without any code changes (due to that one little demo game someone put out). So that means my idea should work but I don't know how to start it yet.
Here is my dream that I hope to make happen. When the player launches the game it connects to the master server (later on when I figure out how to make AI play this card game good there will be an option for single player) and upon connecting to the master server it loads up a screen of a chat room and enters the person in that chat. So of course the person can chat there then probably on the side of that there will be a window with tables (in the MSN zone style games I believe) where people can sit down at a table and when enough people sit that game launches so the screen changes to in that game and they start playing.
I haven't been able to find any good guides on doing much of any of that, so I will try to learn it over the next few days and try to get it going somehow. In the meantime I may start working on some of my awful graphics skills to set up some guis to give an idea of how it should look and if they're too ugly find someone who is willing to spend a little time making good ones.
my basic thought flow so far seems like most of this networking shouldn't be toooo bad
-auto connect to masterserver on load
- on connect place person's name in box that lists people there
- bottom of chat box has a text field box for person to type in when they hit enter or click send it sends it
to master server and master server updates everyone's chat box
- person clicks on one of the table's and sends a message to server saying they took that spot
- server checks to make sure spot is still open and is so puts a marker there, sends update on that
window to all connected
- when given table reaches set amount (first person to sit down would specify 3-6 players) server sends
message to all those machines updates image on the games window to everyone else as in progress
Now what I don't know at all yet is how to set each one of those games as a seperate game on the master server, hopefully it would be as easy as an array but have to learn more to know. So it all seems possible just have to figure it out.
About the author
Recent Blogs
• <edit>• My thoughts, and my farewell
• some progress on cards
• teaching my computer to play cards
• I'm not dead
#2
12/06/2006 (2:33 am)
Unfortunately the checkers tutorial was way over my head when trying to learn networking in TGB. It really is overkill for learning the basics(although I haven't looked at the 1.1.3 example). I'm working on the simplest networked example I can possibly think of. It is less than 50 lines of script and it really is the basics. The client can run a command on the server to say hi in the console, and the server can run a command on each client to say hi in their consoles. Let me know if you want to take a look at it.
#3
@bentz I would love to take a look at that, sounds like that would help get me headed in the right direction on the meeting chat room part
12/06/2006 (1:54 pm)
@ Eastman, yes the checkers tutorial is nice and gives me a great direction on the game play itself when all the players are loaded in the game, it doesn't help much with setting up a master server meeting place and having the master server the run an instance of the game for each group of people.@bentz I would love to take a look at that, sounds like that would help get me headed in the right direction on the meeting chat room part
#4
www.garagegames.com/mg/forums/result.thread.php?qt=54851#412805
12/06/2006 (10:01 pm)
J - I've posted the link to my example in the network forums for the community...www.garagegames.com/mg/forums/result.thread.php?qt=54851#412805
#5
You could possibly find some examples on using the TCPObject, I believe I wrote a few a while back -- not sure if the sample archives are still on my site for download though (have to double check later this evening).
As far as a chat room, you'd probably be best setting something up similiar to IRC -- either read the IRC RFC and mimick it directly, or just make up your own "protocol" and do a mock IRC implementation.
As for the seperate games, an outside server instance would most likely do the best job -- TGB's networking is turn-based, meaning that the client sends a command to the server, and the server responds -- there is no real "real time" networking that would work 100%, however, you only need turn-based networking anyhow as your only doing something when something happens -- the server won't be moving objects without a player interacting with them first ...
Do keep us updated on your progress with networking ... I'm curious.
12/08/2006 (6:47 am)
@J, as I mentioned in an earlier post you wrote -- the master server for this particular game, would most likely be best served as something not written in TGB.You could possibly find some examples on using the TCPObject, I believe I wrote a few a while back -- not sure if the sample archives are still on my site for download though (have to double check later this evening).
As far as a chat room, you'd probably be best setting something up similiar to IRC -- either read the IRC RFC and mimick it directly, or just make up your own "protocol" and do a mock IRC implementation.
As for the seperate games, an outside server instance would most likely do the best job -- TGB's networking is turn-based, meaning that the client sends a command to the server, and the server responds -- there is no real "real time" networking that would work 100%, however, you only need turn-based networking anyhow as your only doing something when something happens -- the server won't be moving objects without a player interacting with them first ...
Do keep us updated on your progress with networking ... I'm curious.
#6
Just curious, haven't heard from you in a while -- have been looking forward to hear about your progress.
12/19/2006 (5:16 pm)
@J,Just curious, haven't heard from you in a while -- have been looking forward to hear about your progress.

Associate Tom Eastman (Eastbeast314)