commit 8ad44e48c1ddd2964da4808830f97e794af651a8 from: marcus date: Tue Aug 21 06:39:45 2007 UTC send protocol replies in blocks to avoid splitting them between packets. (to avoid confusing devices) commit - 96a85dcccd6ea9558480f038fc533b22f312d6f7 commit + 8ad44e48c1ddd2964da4808830f97e794af651a8 blob - 656cbbb1aad9a4a0f877eaad55687381b6955821 blob + 14b7ccc5f22aa6c7f6b35672251b53e344033d95 --- de/mud/telnet/TelnetProtocolHandler.java +++ de/mud/telnet/TelnetProtocolHandler.java @@ -197,10 +197,7 @@ public abstract class TelnetProtocolHandler { */ public void sendTelnetControl(byte code) throws IOException { - byte[] b = new byte[2]; - - b[0] = IAC; - b[1] = code; + byte[] b = {IAC, code}; write(b); } @@ -215,12 +212,11 @@ public abstract class TelnetProtocolHandler { System.err.println("not allowed to send NAWS? (DONT NAWS)"); return; } - write(IAC);write(SB);write(TELOPT_NAWS); - write((byte) (columns >> 8)); - write((byte) (columns & 0xff)); - write((byte) (rows >> 8)); - write((byte) (rows & 0xff)); - write(IAC);write(SE); + byte b[] = {IAC, SB, TELOPT_NAWS, + (byte) (columns >> 8), (byte) (columns & 0xff), + (byte) (rows >> 8), (byte) (rows & 0xff), + IAC,SE}; + write (b); } @@ -507,10 +503,9 @@ public abstract class TelnetProtocolHandler { Dimension size = getWindowSize(); receivedDX[b] = DO; if(size == null) { + byte wontbuf[] = { IAC, WONT, TELOPT_NAWS }; // this shouldn't happen - write(IAC); - write(WONT); - write(TELOPT_NAWS); + write(wontbuf); reply = WONT; sentWX[b] = WONT; break; @@ -521,12 +516,14 @@ public abstract class TelnetProtocolHandler { sendbuf[1]=WILL; sendbuf[2]=TELOPT_NAWS; write(sendbuf); - write(IAC);write(SB);write(TELOPT_NAWS); - write((byte) (size.width >> 8)); - write((byte) (size.width & 0xff)); - write((byte) (size.height >> 8)); - write((byte) (size.height & 0xff)); - write(IAC);write(SE); + byte nawsbuf[] = { + IAC,SB,TELOPT_NAWS, + (byte) (size.width >> 8), + (byte) (size.width & 0xff), + (byte) (size.height >> 8), + (byte) (size.height & 0xff), + IAC,SE }; + write (nawsbuf); break; default: if(debug > 2) System.err.println(""); @@ -568,7 +565,8 @@ public abstract class TelnetProtocolHandler { break; } if(reply != sentWX[b+128] || DONT != receivedDX[b+128]) { - write(IAC);write(reply);write(b); + byte replybuf[] = {IAC, reply, b}; + write(replybuf); sentWX[b+128] = reply; receivedDX[b+128] = DONT; }