Game Development Community

Multiplayer server... I just dont get it

by Manni Medeiros · in Torque 3D Professional · 03/07/2011 (6:59 pm) · 11 replies

Generally I learn by doing not reading but there are not many code examples for me to break apart and figure things out. I read the documentation on everything I could find and have read about 1000 posts on what im looking for but so far nothing seems to fit what I need. There have been posts ranging from about 2002 to 2009 although not many fron the last 2 years that Ive read about the various ways to do this but none actually show how just debates mostly... ive also read everything on networking at the below site:
http://www.garagegames.com/community/forums/viewthread/84535

So what I am hoping is that someone can point me in the right direction for what i need. Now what im looking for is a tutorial or code that I can rip apart that will show me how to setup a simple server with mySql (This is already setup on my PC for php) and a client that sends simple information to said server (either php, java or torque server side system) for updates and then have the server send info to the client (torque3d) updating something. I am not asking for anyting super useful maybe a login system and sending say an xp total to the server and the server seding say stats updates. This should allow me to see how the networking works and then I can expand from there. I am fine with any method I know most web based languages i just am not sure to interface with torque and based on various contradictions made in the the forums as to if torque is used on the server side.

What im looking to accomplish in the end is a simple gui based point and click persistant world multiplayer game with some 3d stuff added after. So this means to learn what i need to start i need a client login(So i see how it works), client clicks button server recieves info and server reports something back. Then I can expand on that. The problem I have found through reading over 1k posts is that there dosnt seem to be some sort of tutorial for torque code to walk you through this sort of thing, maybe im wrong maybe I missed it maybe there something out there if so let me know!

From what i can tell it appears that i would want php talking to client and reverse and php reporting to mysql and reverse but im not sure as that just appears to be one implimentation also httpobject maybe what i want but i cannot seem to find much info on either of these.

Sorry for the long post and possible spelling mistakes but i wanted to be very clear, at this point ive spent money and almost 3 weeks time but i dont even have a place to start yet, although I know way to much about the end now, lol. (Example I made a single player version of the game although not fully complete, Ive created custom gui's although they need alot of polish and alot more of little things that are not really useful at this point.)

About the author

Awkward Monkey was created by me and consists of me my wife and a few friends we are looking into expanding and love developing. Http://www.awkwardmonkey.com


#1
03/07/2011 (11:10 pm)
Hi,

I will start:
1/ you need to find the resource to implement mysql in TGEA/T3D. There is one, so you must dig in the resource section to get it and implement it.
2/ If you want to use a Php server between your mysql & your server/client, you need to use HTTPObject or find libcurl resource implementation (if you want to do advanced stuff).
3/ You won't find any source code or sample that will fit your request because it's a "advanced" modification of T3D compare to the stock source. The stock source multiplayer part allow you to quickly create fps multiplayer game.Once you want to add persistance, character customisation etc.. you need to look for resources or build them yourself.

Honestly, I'm in a middle of a mmo implementation since 2 year, and the community resources are just excellent but they won't cover for sure everything that you want.

So I would suggest that you learn piece by piece and move slowly, the knowledge of T3D will take a long time :D

Good luck!
Look @ mmo in the search panel, there are some useful threads that compile a lot of resource/information.
#2
03/08/2011 (6:40 am)
I'd say that you should also look at the mySQL SDK documentation to see how it's intended to be integrated as well.
#3
03/21/2011 (11:03 am)
Ok So i Now think I've read everything I can find on MySQL integration into a server and all ther server posts and tutorials I could find. This answered some questions and I now understand httpobject and other systems as well but Structure wise there seems to be some blanks that need filling in and I am hoping someone can help me figure this out.

Here is what I think I should be doing:
Client ---(httpObject)---> Server ---(PHP)---> MySQL ---(PHP)---> Server ---(httpObject)---> Client

Now the client and server are both Torque and MySQL database's to store persistant info. Now of course this gets more complicated as you add in expandability but this appears to be the basic concept. Also maybe a sqllite database on the player side to store irrelavant data.

Now I am not sure if this is right... Ive seen some people refer to server/client but they never say what is used so I am only making an educated guess. I also saw other setups but i believe this seems to be the safest way to stop sql injection and php scripts.

Please let me know If I am on the right path or if my compass is off and where I made my mistake.
#4
03/22/2011 (6:59 am)
Manni - Looks about right on the conceptual level. Now it's time for you to start setting up your SQL statements for passing data.

Look at www.garagegames.com/community/resources/view/20903 and www.garagegames.com/community/resources/view/20908 - Robert talks about setting up a server side SQL database using PHP. He also references another of his resources for adding security, and you might need to add that first to get it running right.

You might have read them already though - they're pretty short.
#5
03/22/2011 (8:45 am)
Thos should help alot, That will keep me from having to code everything by myself. Now i gotta set this up and work a login system using facebook or live accounts so you dont need to create a new account. Once completed I should have a fully working game in under 3 months from torque (I was working on the same game almost a year with Panda3d.)

If I have further networking questions I will put them here.
#6
03/22/2011 (7:12 pm)
You can always make adjustments to not use the security portions if you are not concerned too much about it.

The reason for security there is if you plan on using "Secure" or "Authorized" servers. If you want a more full scale rank/progression, you should probably install the crypto and then use a public key cryptography module (RSA/DSA) to ensure the servers are not trying to bypass rank functions.
#7
03/23/2011 (8:16 am)
Manni - What you posted isn't quite right

Client ---(httpObject)---> Server ---(PHP)---> MySQL ---(PHP)---> Server ---(httpObject)---> Client

Torque3D is both a client and server as you say but it doesn't use HTTPObject, it's a bespoke unencrypted network layer communicating via UDP.

For the most part you can use that client and server connection built into Torque for your networking needs between those two elements, however, if you try and scale up then that traffic can become bogged down with things like chat so for larger projects i.e. MMO etc I'd implement a seperate back end for chat and other non-game world stuff (i.e. a patching system) and have the client talk directly to that.

Once you are server side you have a number of options to then get back out to a database:

- MySQL SDK,etc built directly into the server - personally I'd avoid this for a couple of reasons, database access can be slow and you don't want to bog down your game server with data access especially if you get locked rows or something that freezes a writer for a second or two.

Yes you can work around that by using multi-threaded access but that complicates your development a hell of a lot. Secondly it's not easy to then upgrade versions of your database or switch to a different DB.

- HTTPObject - using some PHP, CGI, perl, etc or whatever you wish - this is the easiest route however each request and response has additional header data and authentication must be passed each time thus making it more bandwidth intensive and slower than other methods.

Most of our traffic between game server and backend server i.e. database traffic is small and frequent so that extra data transmitted in the headers can soon add up.

- TCPObject - A raw TCP stream for you to put what you like backend i.e. Python, Lua, etc as the connection persists you can authenticate once on connection and then just send the packets directly. Its faster than using HTTP and is my personal preference, I use Twisted Python for my servers so they are nice and multithreaded.

I believe every little helps

#8
03/24/2011 (8:24 am)
@Robert: Your Posts have really helped me find my way in this which is great! As a new person to the forums I would like to thank you for your time that you have put into learning and informing us!

@Andy: Thanks Man, Due to the nature of the game I am making I will not really have a "Chat" system or things of that nature so that makes this game alot simpler.
Thanks for letting me know about the header info Ill have to test what the difference in transfer that will make with the header and I may have to look at python myself if this is an issue for my game. Athough im not sure if it will be as my clients dont send and recieve much data at all infact only a combination of several items actually sends info to the server so I dont know If this will be an issue.

@Everyone: So this is a good start and now I think I have all the information I need to make this work, Once I have a working beta demo Ill be sure to let everyone here know, since my game is free anyway... (Feel free to spend money in the store though!)

Once this is done though I think I'll make a blog with all of the information I went though and put it all in one place cause there is too much info spread out into tiny chunks in comments of other posts that really should all be in one spot!
#9
03/24/2011 (8:40 am)
If you're not planning on sending lots of requests then I wouldn't worry about using HTTP
#10
03/24/2011 (10:28 pm)
Thanks again for the advice Andy!

I know its probable overkill for the game I am working on right now but I will probable end up using it anyway, my reasoning for this is because of code reusability. If I make a system that I can use in my next game its just copy and paste and make a few small changes. Then I can add the features that I am looking for. The reasoning I think this way is because this is the is just a first in the series of games were planning for T3D and we want to code as little as possible to push the games out faster. The plan is to have the first two of 6 planned games out by the end of the year. (Probable a little over ambitious but hey, what can you do?)
#11
03/24/2011 (10:32 pm)
The engine has text chat built in. No voice, though.