public void doCharacterModeInit() throws IOException {
sendCommand(WILL, ECHO, true);
sendCommand(DONT, ECHO, true); //necessary for some clients
sendCommand(DO, NAWS, true);
sendCommand(WILL, SUPGA, true);
sendCommand(DO, SUPGA, true);
sendCommand(DO, TTYPE, true);
sendCommand(DO, NEWENV, true); //environment variables
}//doCharacterModeInit
public void doLineModeInit() throws IOException {
sendCommand(DO, NAWS, true);
sendCommand(WILL, SUPGA, true);
sendCommand(DO, SUPGA, true);
sendCommand(DO, TTYPE, true);
sendCommand(DO, LINEMODE, true);
sendCommand(DO, NEWENV, true);
}//doLineModeInit
private void sendCommand(int i, int j, boolean westarted) throws IOException {
rawWrite(IAC);
rawWrite(i);
rawWrite(j);
// we started with DO OPTION and now wait for reply
if ((i == DO) && westarted) setWait(DO, j, true);
// we started with WILL OPTION and now wait for reply
if ((i == WILL) && westarted) setWait(WILL, j, true);
flush();
}//sendCommand
private void setWait(int WHAT, int OPTION, boolean WAIT) {
switch (WHAT) {
case DO:
switch (OPTION) {
case SUPGA:
WAIT_DO_REPLY_SUPGA = WAIT;
break;
case ECHO:
WAIT_DO_REPLY_ECHO = WAIT;
break;
case NAWS:
WAIT_DO_REPLY_NAWS = WAIT;
break;
case TTYPE:
WAIT_DO_REPLY_TTYPE = WAIT;
break;
case LINEMODE:
WAIT_DO_REPLY_LINEMODE = WAIT;
break;
case NEWENV:
WAIT_DO_REPLY_NEWENV = WAIT;
break;
}
break;
case WILL:
switch (OPTION) {
case SUPGA:
WAIT_WILL_REPLY_SUPGA = WAIT;
break;
case ECHO:
WAIT_WILL_REPLY_ECHO = WAIT;
break;
case NAWS:
WAIT_WILL_REPLY_NAWS = WAIT;
break;
case TTYPE:
WAIT_WILL_REPLY_TTYPE = WAIT;
break;
}
break;
}
}//setWait
private boolean WAIT_DO_REPLY_SUPGA = false;
private boolean WAIT_DO_REPLY_ECHO = false;
private boolean WAIT_DO_REPLY_NAWS = false;
private boolean WAIT_DO_REPLY_TTYPE = false;
private boolean WAIT_DO_REPLY_LINEMODE = false;
private boolean WAIT_LM_MODE_ACK = false;
private boolean WAIT_LM_DO_REPLY_FORWARDMASK = false;
private boolean WAIT_DO_REPLY_NEWENV = false;
private boolean WAIT_NE_SEND_REPLY = false;
/**
* Are we waiting for a WILL reply?
*/
private boolean WAIT_WILL_REPLY_SUPGA = false;
private boolean WAIT_WILL_REPLY_ECHO = false;
private boolean WAIT_WILL_REPLY_NAWS = false;
private boolean WAIT_WILL_REPLY_TTYPE = false;