Permalink
Browse files

No longer calls lineReceived when line is empty

  • Loading branch information...
MattTuttle committed May 29, 2014
1 parent 08ae80c commit cb8d1855e21c971c00cccd6154841297f7052ff3
Showing with 23 additions and 20 deletions.
  1. +23 −20 hxnet/protocols/Telnet.hx
View
@@ -5,6 +5,8 @@ import haxe.io.Input;
import haxe.io.Bytes;
import haxe.io.BytesOutput;
using StringTools;
/**
* Telnet protocol
*/
@@ -45,35 +47,36 @@ class Telnet extends hxnet.base.Protocol
{
handleIAC(command, line.charCodeAt(++i));
}
last = i;
last = i + 1;
}
i += 1;
}
buffer += line.substr(last, i - last);
buffer += line.substr(last, line.length - last);
if (promptCallback != null)
buffer = buffer.trim();
if (buffer != "")
{
// save current callback for comparison
var callback = promptCallback;
if (callback(buffer))
{
// don't set to null if a different prompt has been set
if (promptCallback == callback)
promptCallback = null;
}
else
if (promptCallback != null)
{
cnx.writeBytes(promptBytes);
// save current callback for comparison
var callback = promptCallback;
if (callback(buffer))
{
// don't set to null if a different prompt has been set
if (promptCallback == callback)
promptCallback = null;
}
else
{
cnx.writeBytes(promptBytes);
}
return;
}
return;
}
lineReceived(buffer);
lineReceived(buffer);
}
}
public function iacWill(code:Int):Void { iacSend(WILL, code); }
public function iacWont(code:Int):Void { iacSend(WONT, code); }
private inline function iacSend(command:Int, code:Int):Void
{
var out = new BytesOutput();
@@ -83,7 +86,7 @@ class Telnet extends hxnet.base.Protocol
cnx.writeBytes(out.getBytes());
}
public function handleIACData(code:Int, data:Bytes) { }
private function handleIACData(code:Int, data:Bytes) { }
private function handleIAC(command:Int, code:Int) { }
/**

0 comments on commit cb8d185

Please sign in to comment.