Game Development Community

dev|Pro Game Development Curriculum

TorqueScript based custom chat client & server

by John Vanderbeck · 04/01/2004 (8:28 pm) · 17 comments

Download Code File

The included zip file contains everything except the executable, because of file size limits on resources. Simply stick TorqueDemo.exe in there, and rename it to "chat.exe" if you want the included batch files to operate properly.

As seen in a few places before, this is the full release of the custom chat server and client written in TorqueScript. Hopefully others can learn from this, or adapt it to thier use. This was written from the ground up with the idea that it would be used as an instructional tool, so it should be real easy to understand and follow.

This is written using TCPObject and illustrates pretty much the complete useage of that object, including how to setup a server and spawn off connected clients, which is key to using this object.

Enjoy!

[EDIT] Grr stupid bug in the server that I missed. It was sending down the wrong username on a login command. The right user logged in, but the command sent to the client so that the client can keep track of the logged in users was bad and always sent "Guest". Fixed and reuploaded the code.

#1
04/01/2004 (9:23 pm)
Really cool and much needed. Thanks!
#2
04/01/2004 (9:51 pm)
Thanks, John - I'll make sure this goes to good use ;-)
#3
04/02/2004 (6:28 am)
Please let me know if you have any problems or find any bugs with it. I finished this late last night so something bad might have crept in :)
#4
04/05/2004 (7:48 pm)
Maybe I am missing something but when I execute these on the same machine I get a syntax error when I attempt to pass this on the client:

login:username

Are there any other tricks to using this that I am missing? Sorry I am new to Torque
#5
04/06/2004 (11:14 am)
Hmm I had posted a response to this earlier today and now I see it never showed up.. Sigh.

What is here is really for learning and demonstration purposes. Normally you'd hook a GUI in first.

However with that said, you CAN use it as is. There are three functions you would use.

chatConnect("Server name or IP", port, "username");
The above function connects to the specified server (Name or IP) and port. Once connected it automaticly logs the user in with the specified username

chatSendChat("chat message");
This sends your chat message.

chatLogout();
The above command will log the user out of the server and disconnect.
#6
07/19/2004 (2:21 am)
do any of you have a successful GUI for this awesome chat. I'm new to creating GUI's and was wondering if you, john, had a gui that you felt you didn't want to upload. If anyone does contact me at foocumber@gmail.com ^.^ thank you!!! ^.^
#7
08/03/2004 (6:41 am)
I had one, but it was really a crapy layer just to test everything. I don't even know if I still have it but Iwill take a look.
#8
04/20/2005 (6:48 am)
Hi, I tried this sample and i have problem. If I write to chat client console:

% login:user1

client always write: Syntax error in input.

Why?
#9
04/20/2005 (7:15 am)
That is a command for the chat system, but not for Torque itself. When you enter it into the console like that then Torque thinks its a Torque script command which it isn't so it errors.
#10
04/20/2005 (7:17 am)
so as command? Wow sorry. :)

example:

chatProcessLine("login:AndyGFX");


It's OK?
#11
04/27/2005 (3:26 pm)
As in:
chatConnect("127.0.0.1", 20010, "AndyGFX");
chatSendChat("Am I logged in?");
chatLogout();
#12
11/05/2005 (8:22 pm)
Took me about 15 mins to get it working in TGE 1.3 with a dedicated server.
Thank you tons.

Ari
#13
03/07/2008 (8:31 am)
I think I have this right. But let me ask anyway. It seems like I need to take the code in the main.cs file in the chatClient directory just below the package declaration and copy to a new file to load into my game on the client side. Do I have this correct?
#14
06/04/2008 (7:11 pm)
The chat client is working fine. thanks.
but I have few queries.
Can this chat be used over internet where the client is behind a proxy/firewall. In that case what extra needs to be done?
what is the maximum number of connections the server can handle? if its is currently, Is there a way to increase it?
#15
08/17/2008 (4:01 pm)
Best reference for TCPObject out there. Thanks for the hard work figuring this out, John!
#16
03/05/2009 (4:27 am)
How exactly do i get this working in TGEA 1.7.1 it dosnt really have any instructions
#17
07/17/2012 (8:49 am)
Since the Resource link is dead: 5457.torquechat.zip