Chat Server + Game Server: Possible?
by elvince · in Torque 3D Professional · 08/19/2009 (4:22 pm) · 14 replies
Quick question in term of design.
I'm building a game that will required chat capatibility. Players will be on different Torque Server instance but I want them to be able to chat between all of them. More or less like in MMORPG, you can always talk to your guild,zone, send PM etc...
In term of design, it seems that I will require to have two connections on the client side: One on the game server and one on the Chat server.
Is it the right direction to do this? Is it something that will be Scripts only or this will involve C++ changes?
My initial thougths were to leverage existing ChatCmd and the ressource for ChatCommand.
Thanks for your help,
Strange issue:
If you want the server to be in console mode only, I didn't find a way to do that without adding args -Dedicated. Even if I set the variable Dedicated to true the Gui screen is loaded + Console
I'm building a game that will required chat capatibility. Players will be on different Torque Server instance but I want them to be able to chat between all of them. More or less like in MMORPG, you can always talk to your guild,zone, send PM etc...
In term of design, it seems that I will require to have two connections on the client side: One on the game server and one on the Chat server.
Is it the right direction to do this? Is it something that will be Scripts only or this will involve C++ changes?
My initial thougths were to leverage existing ChatCmd and the ressource for ChatCommand.
Thanks for your help,
Strange issue:
If you want the server to be in console mode only, I didn't find a way to do that without adding args -Dedicated. Even if I set the variable Dedicated to true the Gui screen is loaded + Console
About the author
Recent Threads
#2
08/19/2009 (6:55 pm)
it could even be done just on the server and it would be scripted. For an example take a look at the tribes2 rpg file stuff I remember they did a Guild / Local zone / Global zone chat
#3
I read in forum by using TCPObject, you are not leveraging torque network compression & security? I'm not sure if this is true, but if yes, this is clearly something that I want to keep within my dev.
@JesseL
From What I saw, this is using jsut 1 server and not 1 game server + 1 chat server.
But for command/team/say function this is a good sample.
Another issue I face this morning, the commandToServer is "single" connection. SO this is why I'm not sure I can handle 2 connection easyly or I will require to use the TCPObject as in Chat Server & client ressource
08/20/2009 (3:20 am)
@Manoel, I read in forum by using TCPObject, you are not leveraging torque network compression & security? I'm not sure if this is true, but if yes, this is clearly something that I want to keep within my dev.
@JesseL
From What I saw, this is using jsut 1 server and not 1 game server + 1 chat server.
But for command/team/say function this is a good sample.
Another issue I face this morning, the commandToServer is "single" connection. SO this is why I'm not sure I can handle 2 connection easyly or I will require to use the TCPObject as in Chat Server & client ressource
#4
However, since chatting would simply involve passing commandToServer and commandtoClient commands around, and those hardly take advantage of security features (it's just strings passing around), I think it's overkill to use a Torque executable as a chat server, when there are much more efficient solutions for chat servers out there.
08/20/2009 (11:07 am)
I think you can have multiple gameConnections, because I'm pretty sure I did that by accident when setting up a custom connection pipeline in the scripts and ended up with double the ghosts or something.However, since chatting would simply involve passing commandToServer and commandtoClient commands around, and those hardly take advantage of security features (it's just strings passing around), I think it's overkill to use a Torque executable as a chat server, when there are much more efficient solutions for chat servers out there.
#5
08/20/2009 (11:34 am)
Why have 2 connections from the client when you could just have the server forward messages to other servers on its own?
#6
08/20/2009 (11:44 am)
@Michael: that's a better idea. Sounds much safer and reduces the overall number of connections in the server infrastructure.
#7
So you mean it's better to have all the game servers talking each other to handle this?
So that's means all game server will have a connection to all others servers or you are using a database to store the messages to spread out of the game server and put a schedule task on each server to retrieve the information?
How will you handle "whisper" in this situation? Will you spread the message to all servers and all server will look if the player is connected on this server, if yes send the message?
So you will use X (number of server) times the cpu workload required to do this single task.
This can be nothing for 2 servers with 10 players, but what if we are targetting 300 with 10/15 game servers?
I'm not an expert in T3D, this is why I may ask foolish question.
@Manoel,
"when there are much more efficient solutions for chat servers out there." What are you thinking about? Do you have idea that can be easily integrated with T3D?
The only thing I though was IRC, but clearly in term of security this is a Big hole on your server side, or you need to well know how to secure your server to avoid hacking.
by the way, thanks for your answers.
08/21/2009 (3:36 am)
@Michael,So you mean it's better to have all the game servers talking each other to handle this?
So that's means all game server will have a connection to all others servers or you are using a database to store the messages to spread out of the game server and put a schedule task on each server to retrieve the information?
How will you handle "whisper" in this situation? Will you spread the message to all servers and all server will look if the player is connected on this server, if yes send the message?
So you will use X (number of server) times the cpu workload required to do this single task.
This can be nothing for 2 servers with 10 players, but what if we are targetting 300 with 10/15 game servers?
I'm not an expert in T3D, this is why I may ask foolish question.
@Manoel,
"when there are much more efficient solutions for chat servers out there." What are you thinking about? Do you have idea that can be easily integrated with T3D?
The only thing I though was IRC, but clearly in term of security this is a Big hole on your server side, or you need to well know how to secure your server to avoid hacking.
by the way, thanks for your answers.
#8
When a client sends a message, it is sent to the game server that client is connected to. The game server forwards the message to the chat server (which will probably be on the same network) if required (if the message is targeted at a player on the same server, it doesn't even need to be sent to the chat server at all). The chat server then sends the messages to the other game servers based on the message type (a PM only needs to be sent to the server the target player is on, as example).
It is also more secure since the chat is subject to the same security as your game.
About chat servers... all you need is to know their chat protocol specification. There's XMPP, the basis of Jabber, which is open source. There are tons of readily usable servers made with XMPP, and at xmpp.org you have full access to the communication protocol.
08/21/2009 (10:56 am)
@Elvince: Michael's idea is having a single central chat server. However, the game servers connect to the chat server, not the clients.When a client sends a message, it is sent to the game server that client is connected to. The game server forwards the message to the chat server (which will probably be on the same network) if required (if the message is targeted at a player on the same server, it doesn't even need to be sent to the chat server at all). The chat server then sends the messages to the other game servers based on the message type (a PM only needs to be sent to the server the target player is on, as example).
It is also more secure since the chat is subject to the same security as your game.
About chat servers... all you need is to know their chat protocol specification. There's XMPP, the basis of Jabber, which is open source. There are tons of readily usable servers made with XMPP, and at xmpp.org you have full access to the communication protocol.
#9
www.garagegames.com/community/resource/view/4968/4#comments
the downloadlink was somewhere in the comments.
08/21/2009 (11:29 am)
you can host an irc server. i saw this implemented in the tge lobby 1.2www.garagegames.com/community/resource/view/4968/4#comments
the downloadlink was somewhere in the comments.
#10
Thanks for the explanation. I will look to go in this way with a chat server on the server side with a connection between game server and chat server.
I'm not sure using a chat server XMPP will be relevant in this design. As we will have 10 game server = 10 "client" for the chat server, but in reality it could be 50 players. So I'm not sure this can be adressed easily. XMPP server may have been a solution if we want all clients to connect to it (first design)
@Arne,
IRC server can be a solution but I'm not sure if I will be enough confident in term of security. And if you want to put it only on server side, we will face the same design issue as with XMPP server.
08/22/2009 (3:40 am)
@ManoelThanks for the explanation. I will look to go in this way with a chat server on the server side with a connection between game server and chat server.
I'm not sure using a chat server XMPP will be relevant in this design. As we will have 10 game server = 10 "client" for the chat server, but in reality it could be 50 players. So I'm not sure this can be adressed easily. XMPP server may have been a solution if we want all clients to connect to it (first design)
@Arne,
IRC server can be a solution but I'm not sure if I will be enough confident in term of security. And if you want to put it only on server side, we will face the same design issue as with XMPP server.
#11
In GameConnection::onConnectionEstablished, client will by default set mServerConnection to your newly created connection.
commandToServer function first check if the connection is mServerConnection, if not, return. What you could do is just copy this function, rename it to commandToChatServer, and check to see if one connection is mChatConnection.
08/22/2009 (4:19 am)
Yes, you can enable this by doing some modifications to the cpp files like NetConnection or GameConnection, on client side, mServerConnection holds the connection to the game server, so you can add another connection, say 'mChatConnection' to hold your connection to chat server.In GameConnection::onConnectionEstablished, client will by default set mServerConnection to your newly created connection.
void GameConnection::onConnectionEstablished(bool isInitiator)
{
...
mServerConnection = this; // key line
...
}In order to tell a chat conn from a game conn, you can replace the above "key line" with if(mConnectArgc > 1 && !dStrcmp(mConnectArgv[1],"CHATFLAG"))
mChatConnection = this;
else
mServerConnection = this;The mConnectArgv was set via scripts.commandToServer function first check if the connection is mServerConnection, if not, return. What you could do is just copy this function, rename it to commandToChatServer, and check to see if one connection is mChatConnection.
#12
But in this case, how do you handle all gameconnection event. For example the onConnectionAccepted following your code, might be the same function in Torque script as the regular connection. So that's means each time I will use one event, I have to always differentiate wich connection I'm talking about.
Is that true? Did I miss something?
ex: GameConnection::onConnectionAccepted(%this)
08/23/2009 (10:58 am)
nice approach Huan.But in this case, how do you handle all gameconnection event. For example the onConnectionAccepted following your code, might be the same function in Torque script as the regular connection. So that's means each time I will use one event, I have to always differentiate wich connection I'm talking about.
Is that true? Did I miss something?
ex: GameConnection::onConnectionAccepted(%this)
#13
Create the connection
%conn = new GameConnection(ChatConnection);
Event to handle this connection
function ChatConnection::onConnectionAccepted(%this)
if you don't put that you go in
GameConnection::onConnectionAccepted(%this)
I implement your suggestion Huan, and it's working perfectly. Thanks!
08/23/2009 (1:01 pm)
I find away to override this default behaviour.Create the connection
%conn = new GameConnection(ChatConnection);
Event to handle this connection
function ChatConnection::onConnectionAccepted(%this)
if you don't put that you go in
GameConnection::onConnectionAccepted(%this)
I implement your suggestion Huan, and it's working perfectly. Thanks!
#14
08/23/2009 (10:27 pm)
Glad that helps, elvince.:)
Associate Manoel Neto
Default Studio Name