Want to connect the client to 2 servers..
by Flybynight Studios · in Torque Game Engine · 12/09/2007 (8:50 pm) · 5 replies
Let me try and explain..
I want the client's main rendering screen to be local.. Meaning they run their own server process and connect to themselves.
I want the game logic to be handled by my server.. Things like chat (which I have an IRC module I can use) but more specifically things like authentication, object selection etc etc..
The reason for doing this is that the current project I am working on supports fast (5-10 minute) 2 player games. But I want to keep the concept scaleable so that literally hundreds/thousands of players could be online simultaneously in hundreds of different 2 player games.
Obviously having hundreds of Torque instances running to support 2 persons each seems very inefficient. I know other people have done things like this where the local client server handles the rendering and a second server connect handles other things.
Is this a simple process to work around or do I need to get into the network layer?
Thank you in advance.
I want the client's main rendering screen to be local.. Meaning they run their own server process and connect to themselves.
I want the game logic to be handled by my server.. Things like chat (which I have an IRC module I can use) but more specifically things like authentication, object selection etc etc..
The reason for doing this is that the current project I am working on supports fast (5-10 minute) 2 player games. But I want to keep the concept scaleable so that literally hundreds/thousands of players could be online simultaneously in hundreds of different 2 player games.
Obviously having hundreds of Torque instances running to support 2 persons each seems very inefficient. I know other people have done things like this where the local client server handles the rendering and a second server connect handles other things.
Is this a simple process to work around or do I need to get into the network layer?
Thank you in advance.
#2
If you host your servers on Windows 2003 you can have seamless clustering / network load balancing. Win 2k3 (possibly 2000 Server as well, but I'm not sure off hand) can be easily configured to distribute traffic received through one end point across a large number of physical servers.
12/10/2007 (12:21 am)
You could use torque as the client and then use a TCPObject or HTTPObject to talk to a web server or TCP app and handle your game rules / game logic in the outside system.If you host your servers on Windows 2003 you can have seamless clustering / network load balancing. Win 2k3 (possibly 2000 Server as well, but I'm not sure off hand) can be easily configured to distribute traffic received through one end point across a large number of physical servers.
#3
So it's pretty easy!
The other thing you will need to do is to get into the script. By default when a connection is made to a server, a mission load sequence is initiated, you will want to get in and stop the mission load if certain arguments were passed in the connection event, make the arguments up yourself.
12/10/2007 (3:11 am)
You can have multiple server connections. What I did was setup a CommandToNamedServer function, which is pretty much the same thing as commandtoClient. Your only problem is that your 'default' server connection will be the most recent one connected. That's the one that the regular CommandToServer will bounce off of. To get around this, I setup a 'SetServerConnection' function.So it's pretty easy!
The other thing you will need to do is to get into the script. By default when a connection is made to a server, a mission load sequence is initiated, you will want to get in and stop the mission load if certain arguments were passed in the connection event, make the arguments up yourself.
#4
and also,
You call that second function anytime you make a new connection, to set the default server connection.
12/10/2007 (3:15 am)
Here is what we've used:ConsoleFunction( commandToNamedServer, void, 3, RemoteCommandEvent::MaxRemoteCommandArgs + 2, "(NetConnection server, string func, ...)"
"Send a command to the server.")
{
NetConnection *conn;
if(!Sim::findObject(argv[1], conn))
return;
sendRemoteCommand(conn, argc - 2, argv + 2);
}and also,
//When maintaining multiple server connections, this lets us override the main connection
//that gets returned by getConnectionToServer type stuff
ConsoleFunction( setServerConnection,void, 2, 2, "setServerConnection(S32)" )
{
NetConnection *conn;
if(!Sim::findObject(argv[1], conn))
return;
NetConnection::setServerConnection(conn);
}You call that second function anytime you make a new connection, to set the default server connection.
#5
@Matt: I had considered that Matt and depending on the size and scaleability I need it's very possible that I will eventually write a server side code to run the game logic. Thanks for the suggestion.
@Dave: I don't know if a lot of people will see Dave's example for what it is but he has basically just handed you the keys to unlocking a whole new dimension of power in Torque with the minor adjustment of a couple of simple lines of code. Sure this accomplishes what I need but it also (very effectively) opens the door to creating "seamless" worlds in TGE, multiple server connects for AI botting etc.
Thank you for being so clear and sharing your expertise Dave. I will work on getting those changes in and seeing what I can do with it. I suspect it will do exactly what I need it to.
12/10/2007 (9:23 am)
First off, both excellent responses. Thank you guys.@Matt: I had considered that Matt and depending on the size and scaleability I need it's very possible that I will eventually write a server side code to run the game logic. Thanks for the suggestion.
@Dave: I don't know if a lot of people will see Dave's example for what it is but he has basically just handed you the keys to unlocking a whole new dimension of power in Torque with the minor adjustment of a couple of simple lines of code. Sure this accomplishes what I need but it also (very effectively) opens the door to creating "seamless" worlds in TGE, multiple server connects for AI botting etc.
Thank you for being so clear and sharing your expertise Dave. I will work on getting those changes in and seeing what I can do with it. I suspect it will do exactly what I need it to.
Torque Owner Flybynight Studios
The main reason for the server is that it controls the game mechanics. In this case, a card game. The results from that card game inpact the player's profiles and allow them to accumulate resources which they can use to build themselves a kingdom in a virtual world. Allowing to players to connect to each other would take the control from my serverand allow all kinds of cheating and such.
I could set up the games to just spawn their own torque instances for now but it's a completely inefficient use of resources.
The way this works is a game server could host say 200 games.. that's 400 concurrent connects before I have to spawn another game server. Each of the 400 clients do a connect to the same game server but they are assigned a "game#" by the combat queing system. When a client sends a "command" to do something in the game the game server checks the other clientID that is part of that game# and tells that other client what the first player just did. The games arent FPS or any kind of moving around at all. The players are more just seeing an overview of the area and watching the events unfold in the 3D world (which is actually a local server on thier client). The commands from the real "game server" will tell that client to spawn fireballs, move creatures, change attack targets etc. It's a hybrid RTS/MMO.
I have most of the game working now but I really want to figure out this scaling problem befor eI get much further. If it doesnt pan out the way I want it to I will have to completely rewrite the server core and I am totally not intrested in doing that again :)
Thanks for any advice or input.
Mark