TCPObject Response Delay
by Nick Matthews · in Torque Game Engine · 06/12/2008 (2:18 am) · 3 replies
Hey,
I'm currently looking at getting Jabber working in TGE. Jabber is an open-source IM protocol type thing that uses XMPP or something. But anyway, I'm using a TCPObject to connect to a local jabber server on port 5222 - fine.
Next, I send the following line to the server via tcpobject.send(""):
And the expected response from the server comes literally five minutes or so later. Here is what I should be receiving:
DIGEST-MD5 PLAIN ANONYMOUS CRAM-MD5
However I tried this same thing using a basic PHP socket and got an instant response. The even stranger thing was, If I forced the TCPObject to call the onDisconnect by doing tcpobject.connect(otherthing) then closing the other thing, it returned the response I was expecting. So here's what I was doing in a nutshell:
> Connect to 127.0.0.1:5222
> Connected
> Send Line
> Wait for Response
> No Response yet?
> Connect to 127.0.0.1:1080 (A socks server I have)
> Connected
> Close Socks Server
> Disconnected
> Expected Line sent to onLine
So its like the TCPObject is just storing all the server responses, then dumping them all out at once to the onLine callback upon disconnection (note this can't be forced by doing .disconnect, it has to disconnect by timeout or some other method)
I hope I explained it sufficiently - thanks very much to anyone who can give me any insight into the cause of this problem.
I'm currently looking at getting Jabber working in TGE. Jabber is an open-source IM protocol type thing that uses XMPP or something. But anyway, I'm using a TCPObject to connect to a local jabber server on port 5222 - fine.
Next, I send the following line to the server via tcpobject.send(""):
And the expected response from the server comes literally five minutes or so later. Here is what I should be receiving:
However I tried this same thing using a basic PHP socket and got an instant response. The even stranger thing was, If I forced the TCPObject to call the onDisconnect by doing tcpobject.connect(otherthing) then closing the other thing, it returned the response I was expecting. So here's what I was doing in a nutshell:
> Connect to 127.0.0.1:5222
> Connected
> Send Line
> Wait for Response
> No Response yet?
> Connect to 127.0.0.1:1080 (A socks server I have)
> Connected
> Close Socks Server
> Disconnected
> Expected Line sent to onLine
So its like the TCPObject is just storing all the server responses, then dumping them all out at once to the onLine callback upon disconnection (note this can't be forced by doing .disconnect, it has to disconnect by timeout or some other method)
I hope I explained it sufficiently - thanks very much to anyone who can give me any insight into the cause of this problem.
#2
It then keeps jabber working as normal so you can use other normal clients (non TGE) to talk to your jabber server too.
06/12/2008 (9:45 am)
Personally Nick I would create a new class in TGE and inherit from TCPObject that way you can keep TCPObject intact and then just rewrite your TCPObject::parseLine() function.It then keeps jabber working as normal so you can use other normal clients (non TGE) to talk to your jabber server too.
#3
Be careful, if the TCP buffers aren't friendly you may get partial messages. So you may need to think about how to deal with that case; I wouldn't worry till it started happening though.
Ben Garney
coderhump.com/
06/12/2008 (3:10 pm)
Or you might add a flag on TCPObject (to notify you on every TCP input event or just on newline).Be careful, if the TCP buffers aren't friendly you may get partial messages. So you may need to think about how to deal with that case; I wouldn't worry till it started happening though.
Ben Garney
coderhump.com/
Torque Owner Nick Matthews
So the next problem is whether I modify the jabber server to add \n to its output, or whether I remove the newline check for the TCPObject. Does anyone have any recommendations on this front?