/** * Write a <i>do</i> option request to the client. * * @param option the option to send */ public final void writeDoOption(Option option) { send(new byte[]{BYTE_IAC, BYTE_DO, option.code}); }
/** * Write a <i>do</i> option request to the client. * * @param option the option to send */ public final void writeDoOption(Option option) { send(new byte[]{BYTE_IAC, BYTE_DO, option.code}); }
/** * Write a do <i>will</i> request to the client. * * @param option the option to send */ public final void writeWillOption(Option option) { send(new byte[]{BYTE_IAC, BYTE_WILL, option.code}); }
@Override void handleWill(TelnetConnection session) { session.send(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, code, BYTE_SEND, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE}); } @Override
/** * Write a do <i>will</i> request to the client. * * @param option the option to send */ public final void writeWillOption(Option option) { send(new byte[]{BYTE_IAC, BYTE_WILL, option.code}); }
@Override void handleWill(TelnetConnection session) { session.send(new byte[]{TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SB, code, BYTE_SEND, TelnetConnection.BYTE_IAC, TelnetConnection.BYTE_SE}); } @Override
/** * Write data to the client, escaping data if necessary or truncating it. The original buffer can * be mutated if incorrect data is provided. * * @param data the data to write */ public final void write(byte[] data) { if (sendBinary) { int prev = 0; for (int i = 0;i < data.length;i++) { if (data[i] == -1) { rawWrite(data, prev, i - prev); send(new byte[]{-1, -1}); prev = i + 1; } } rawWrite(data, prev, data.length - prev); } else { for (int i = 0;i < data.length;i++) { data[i] = (byte)(data[i] & 0x7F); } send(data); } }
/** * Write data to the client, escaping data if necessary or truncating it. The original buffer can * be mutated if incorrect data is provided. * * @param data the data to write */ public final void write(byte[] data) { if (sendBinary) { int prev = 0; for (int i = 0;i < data.length;i++) { if (data[i] == -1) { rawWrite(data, prev, i - prev); send(new byte[]{-1, -1}); prev = i + 1; } } rawWrite(data, prev, data.length - prev); } else { for (int i = 0;i < data.length;i++) { data[i] = (byte)(data[i] & 0x7F); } send(data); } }
/** * Handle option <code>DO</code> call back. The implementation will try to find a matching option * via the {@code Option#values()} and invoke it's {@link Option#handleDo(TelnetConnection)} method * otherwise a <code>WON'T</code> will be sent to the client.<p> * * This method can be subclassed to handle an option. * * @param optionCode the option code */ protected void onOptionDo(byte optionCode) { for (Option option : Option.values()) { if (option.code == optionCode) { option.handleDo(this); return; } } send(new byte[]{BYTE_IAC, BYTE_WONT, optionCode}); }
/** * Handle option <code>WILL</code> call back. The implementation will try to find a matching option * via the {@code Option#values()} and invoke it's {@link Option#handleWill(TelnetConnection)} method * otherwise a <code>DON'T</code> will be sent to the client.<p> * * This method can be subclassed to handle an option. * * @param optionCode the option code */ protected void onOptionWill(byte optionCode) { for (Option option : Option.values()) { if (option.code == optionCode) { option.handleWill(this); return; } } send(new byte[]{BYTE_IAC, BYTE_DONT, optionCode}); }
/** * Handle option <code>DO</code> call back. The implementation will try to find a matching option * via the {@code Option#values()} and invoke it's {@link Option#handleDo(TelnetConnection)} method * otherwise a <code>WON'T</code> will be sent to the client.<p> * * This method can be subclassed to handle an option. * * @param optionCode the option code */ protected void onOptionDo(byte optionCode) { for (Option option : Option.values()) { if (option.code == optionCode) { option.handleDo(this); return; } } send(new byte[]{BYTE_IAC, BYTE_WONT, optionCode}); }
/** * Handle option <code>WILL</code> call back. The implementation will try to find a matching option * via the {@code Option#values()} and invoke it's {@link Option#handleWill(TelnetConnection)} method * otherwise a <code>DON'T</code> will be sent to the client.<p> * * This method can be subclassed to handle an option. * * @param optionCode the option code */ protected void onOptionWill(byte optionCode) { for (Option option : Option.values()) { if (option.code == optionCode) { option.handleWill(this); return; } } send(new byte[]{BYTE_IAC, BYTE_DONT, optionCode}); }