Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Hammereditor5

Pages: 1 2 [3]
31
Modification Help / TCP client and server not sending lines [SOLVED]
« on: February 25, 2014, 03:09:40 PM »
EDIT: I now solved the problem by using a different method to run a server socket.


I created a small script today to refresh my memory on how to use TCPobjects (I've not used them for over 6 months).
Code: [Select]
function ServerTCP::onLine(%this, %line)
{
echo(%this.getName() @ ": Line received from client: " @ %line);
}

//The 'ServerTCP' and 'ClientTCP' classes are copied and modified from another forum topic.
function ServerTCP::onConnectRequest(%this, %ipAddr, %socket)
{
   if(isObject(%this.connection[%ipAddr]))
   {
      echo(%this.getName() @ ": Got duplicate connection from" SPC %ipAddr);
      %this.connection[%ipAddr].disconnect();
      %this.connection[%ipAddr].delete();
   }
   echo(%this.getName() @ ": Creating connection to" SPC %ipAddr SPC "...");
   %this.connection[%ipAddr] = new TCPobject("",%socket) { class = ClientTCP; parent = %this; };
}

function ClientTCP::onLine(%this, %line)
{
   echo(%this.getName() @ ": Line received from client: " @ %line @ ". Echoing to client...");
   %this.send("Echo of your line:" SPC %line);
}

function ClientTCP::onConnected(%this)
{
echo(%this.getName() @ ": Client has successfully connected to the server.");
}



function TestClientTCP::onLine(%this, %line)
{
   echo(%this.getName() @ ": Line received from server: " @ %line);
}

function TestClientTCP::onConnected(%this)
{
echo(%this.getName() @ ": Successfully connected to server.");
}

new TCPobject(ServerTCP);
ServerTCP.listen(3009);

//Create a client to test:
$testClient = new TCPobject(ClientTCP);
$testClient.connect("127.0.0.1:3009"); //the TCP server is hosted on the same computer which the TCP client is on
//Now the console echoes "ClientTCP: Successfully connected to server.", and then "ServerTCP: Creating connection to 127.0.0.1:52771...".
$testClient.send("Testing...\r\n");
//Now nothing happens. No text or error messages are echoed inside the console.

As you can see, the ::onLine() function is never being called. Is anything wrong in this code?

32
Modification Help / Using the dedicated server console via STDin
« on: February 22, 2014, 09:10:16 PM »
First, I did not know which section of the forums to put this topic in, since it's a little programming-y.

I was wondering if it is possible to start a Blockland dedi-server, then be able to print text to the console by using the STDin input stream. I made a quick program in Java to test this, but when I sent echo("Testing..."); to the STDin stream, nothing happened. When I tried putting a '%' sign in front of my command, it still did not work.

So I suspect that it's impossible to use the STDin instead of a console window. Is that correct?

33
Modification Help / JSON parser
« on: February 21, 2014, 09:03:10 AM »
I was looking for a JSON text parser for Torquescript, and I found this:
http://forum.blockland.us/index.php?topic=213850.0
Unfortunately, the topic is too old and Github gives a "404" error.
So where can I find a JSON parser?

Pages: 1 2 [3]