Blockland Forums > Modification Help
TCPObjects, how do they work?
<< < (6/8) > >>
Lugnut:
not \r\n\r\n

just \r\n
Wordy:
gave me a error-



apart from that, still nothing
Lugnut:
post code
Wordy:
if(!isObject(WBClient))
   new ScriptObject(WBClient);

function WBClient::Connect(%this)
{
   %server = "69.64.43.11";
   %port = "29000";
   
   if(!isObject(WBConnector))
      new TCPObject(WBConnector);
   WBConnector.connect(%Server @ ":" @ %port);
   MessageBoxOk("","Sent connection request to the server.");
}

function WBConnector::OnConnected(%this)
{
   MessageBoxOk("","Connection has been successful.");
}

function WBConnector::OnConnectFailed(%this)
{
   MessageBoxOK("","Connection to the server failed.");
}

function WBConnector::OnDisconnect(%This)
{
   MessageBoxOK("","Connection to the server has been terminated.");
   WBConnector.delete();
}


and for the server sided bit




   if(!isObject(WBServer))
      new ScriptGroup(WBServer);

   if(!isObject(WBListener))
      new TCPObject(WBListener).listen(29000);
      
   function WBListener::onConnectRequest(%this,%ip,%socket)
   {
      if(isObject(%this.connection[%ip]))
      {
        echo(%this.getName() @ ": Got duplicate connection from" SPC %ip);
        %this.connection[%ip].disconnect();
        %this.connection[%ip].delete();
      }
       echo(%this.getName() @ ": Creating connection to" SPC %ip);
       %this.connection[%ip] = new TCPobject("",%socket) { class = ConnectionTCP; parent = %this; };
   WBServer.add(%this.connection[%ip]);
   }
   function ConnectionTCP::onLine(%this,%line)
   {
      switch$(getWord(%line, 0))
            {
               case "#101":
                  echo("#Test data recieved.");
                  announce("#test data recieved.");
                  return;
               
               default:
                  echo(%line);
            }
   }


i try do .send("#101"); and it just gives that error that i posted before
Greek2me:
You guys might want to look at Truce's Torque Webserver. http://forum.blockland.us/index.php?topic=142682.0
Navigation
Message Index
Next page
Previous page

Go to full version