RejectedSoftware Forums

Sign up

readAllUTF8 never returns?

I'm trying to include support for telnet in order to allow legacy
clients to connect to my game server -- but it seems that readAllUTF8
doesn't return? I'm at a bit of a loss.

Thanks in advance for any feedback.

I have the following code in my static this()

runTask(() {

  listenTCP_s(6969, &initiateTelnet, settings.bindAddresses[0]);// 

This blocks, so we need to run it as a task.

});

listenHTTP(settings, router);

And then initiateTelnet processes text based commands in a similar
fashion to the WebSockets handler.

intiateTelnet then does the following:

while(socket.connected)

  {
Json JsonMsg;
try
  {

        auto msg = socket.readAllUTF8();
        writefln("Do we ever receive a message?", msg );
    mh.handleMessage( msg );
  }
catch( Exception ex )
  {
     writeln(ex.msg);
  }
  }

Re: readAllUTF8 never returns?

Still not sure why this doesn't work. However, I took a look at the
vibednews source code and found readLine() in stream.operations. That
seems to work better for the intended function.

Thanks

On 2013-10-28 22:58:39 +0000, Shammah Chancellor said:

I'm trying to include support for telnet in order to allow legacy
clients to connect to my game server -- but it seems that readAllUTF8
doesn't return? I'm at a bit of a loss.

Thanks in advance for any feedback.

I have the following code in my static this()

runTask(() {

  listenTCP_s(6969, &initiateTelnet, settings.bindAddresses[0]);// 

This blocks, so we need to run it as a task.

});

listenHTTP(settings, router);

And then initiateTelnet processes text based commands in a similar
fashion to the WebSockets handler.

intiateTelnet then does the following:

while(socket.connected)

  {
Json JsonMsg;
try
  {

        auto msg = socket.readAllUTF8();
        writefln("Do we ever receive a message?", msg );
    mh.handleMessage( msg );
  }
catch( Exception ex )
  {
     writeln(ex.msg);
  }
  }


Re: readAllUTF8 never returns?

Am 29.10.2013 01:04, schrieb Shammah Chancellor:

Still not sure why this doesn't work. However, I took a look at the
vibednews source code and found readLine() in stream.operations. That
seems to work better for the intended function.

Yes, readLine is the right choice in this case. readAll and
readAllUTF8 will read everything until the end of the input stream -
which is until the connection is closed by the remote in this case.