Game Development Community

Having 2 servers communicate

by Robin Degen · in Torque Game Engine · 05/09/2006 (1:48 am) · 10 replies

I want to have 2 servers (1 on loopback with the client and one dedicated elsewhere) to communicate with each other. However, i would like to do it in a way that, CommandToServer and CommandToClient (or similar) functions can be used to communicate the two. I was thinking in a way like "CommandToMasterServer" and "CommandToServer".

The reason for this, is i want to have clients host their own game on loopback. Then their movement data will be send to one "big" dedicated server. That dedicated server will send that walk data to all the other clients. Why? Normal movement with > 500 ping. I know this isn't safe (never trust a client).. but that's not really the problem right now.. so i dont need anything for that. Let's say i can trust my clients that are connected.


I hope i explained it good enough.. i didn't really know how to explain it.

#1
05/09/2006 (2:08 am)
An easy way to solve this is to use the TCPObject (search for "TCPObject", there are tutorials available). With this object you can "talk" to each other very easily. I used this too for inter-server connections.
#2
05/09/2006 (3:41 am)
I too use TCPObject to communicate between servers.
#3
05/09/2006 (4:42 am)
Robin, for your purposes, would it not be easier to allow the client to directly move their own character, and ignore packets from the server about that character (or perhaps use them to warp your position only if it drifts out by too much)? You'd probably need to hook into the movement commands being sent to the server..

other than that, yep, TCPObject rocks ;-)
#4
05/09/2006 (7:53 am)
Or you could use a binary TCP Object, thats always fun!

And encrypt the packets.

And dont include text....

But thats just me... =) Me and my optimized, encoded, cool, mmoTCPObject...
#5
05/09/2006 (9:26 am)
Do you and your cool mmoTCPObject also release things like that? or do you keep that private? :P

Anyway, thanks for the help, i'll have a look :)
#6
05/09/2006 (9:56 am)
@Ricky:

Funny, why would you want to use binary? (:

@Robin Degen,

Have you considered SSL? Or to implement your own encryption package and call it before sending away data and before you parse incoming commands? It's not too hard when you get the basics down.

-------------------

Encrypting everything going in and out of an MMO not only eats up alot of CPU, it's also less secure (plaintex vulnerabilities) than carefully chosing what packets to encrypt. Of course this can be helped with different block modes (assuming you're using a blockcipher) like CBC and whatnot, but I still wouldn't do it for performance alone.
#7
05/09/2006 (10:02 am)
Err, well, I fail to see the problem....

I use binary for everything...

Health, Age, Time, Colour of the Sky, etc....

And the encryption is borrowed from a MMO yet to be hacked.

=) Its also very cheap, IE: It requires very little CPU. (Very few packets sent, hence the optimization thang!)

Also, when I'm done with my mmoTCPObject, I want to release it as a MMO TGB/TGE kit. I have some pretty cool stuff in it. =)
#8
05/09/2006 (10:08 am)
Quote:
I use binary for everything...

Health, Age, Time, Colour of the Sky, etc....

That's not binary.

Check out the Binary TCPObject resource for an example on binary transfers of data using Torque's TCPObject and what it infact does.

Quote:
And the encryption is borrowed from a MMO yet to be hacked.

Funny. I would love to hear specifics to that statement. Hehe, "borrowed" - great.

Quote:
=) Its also very cheap, IE: It requires very little CPU. (Very few packets sent, hence the optimization thang!)

Oh really? Sending/receiving packets has nothing to do with CPU load in the case of encryption, it's the cipher that loads the CPU.

I'm not trying to sound mean here, but I seriously doubt that you've got anything of what you're claiming.

I do wish you good luck though, programming can be fun!
#9
05/10/2006 (4:03 pm)
Robin, I'm doing the exact same thing with my MMO project (which a few dozen servers). I have a lightweight PeerConnection class that I use to do everything you describe. I've been meaning to turn it into a resource for a while now; I'll try and get that done soon. It's easier still than an HTTPObject or whatever, and lets you use CommandToPeer() to send info down the wire in script without any hassle.
#10
05/10/2006 (4:14 pm)
That's cool! I've been having some other idea's on how i will handle with different maps etc. So i'll only need one main server. The loader of the maps will be the server on the client's side.

Can't wait to see it!