need some help with tcpobject
by jeepee · in Torque 3D Professional · 01/05/2010 (5:53 pm) · 4 replies
I have been playing around a bit with tcpobject and got it to work, but for some reason only by putting in a delay. That does not seem the proper way of doing this.
I now have this code:
I have this code working with tcpWaitTime set to 500. What would be a better way of doing this? Thanks!
I now have this code:
function getText() {
%udp = new tcpobject(getText);
%udp.connect($textServer@":"@$textServerPort);
schedule($tcpWaitTime,0,getTextReally,%udp);
}
function getTextReally(%uddp)
{
%uddp.send("GET http://"@$textServer@$textPath@$textFile@" \r\n");
}
function getText::onLine(%this, %line)
{
if(%line !$= "")
{
echo ("test:: " @ %line);
ChatHud.addLine(%line);
}
}I have this code working with tcpWaitTime set to 500. What would be a better way of doing this? Thanks!
#2
01/09/2010 (11:14 am)
the proper way would be using the getText::onConnected (onConnectxxxx actually, unsure if it was onConnected) callback. thats being called when the handshaking has been done and the connection is there to send stuff
#3
01/12/2010 (7:35 pm)
Thanks, that was exactly the pointer I needed (it is indeed getText::onConnected). Is the usual approach then to reuse the object to setup another connection when needed, or to destroy the object and creating a new one if needed later on?
#4
01/12/2010 (7:37 pm)
I normally destroy it unless its used directly again and the used protocol I'm running through tcp allows it
Torque 3D Owner jeepee