Java Code Examples for org.apache.commons.net.telnet.TelnetNotificationHandler#RECEIVED_COMMAND

The following examples show how to use org.apache.commons.net.telnet.TelnetNotificationHandler#RECEIVED_COMMAND . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SwitchTelnetClientSocket.java    From daq with Apache License 2.0 6 votes vote down vote up
/**
 * * Callback method called when TelnetClient receives an option negotiation command.
 *
 * @param negotiation_code - type of negotiation command received (RECEIVED_DO, RECEIVED_DONT,
 *     RECEIVED_WILL, RECEIVED_WONT, RECEIVED_COMMAND)
 * @param option_code - code of the option negotiated *
 */
public void receivedNegotiation(int negotiation_code, int option_code) {
  String command = null;
  switch (negotiation_code) {
    case TelnetNotificationHandler.RECEIVED_DO:
      command = "DO";
      break;
    case TelnetNotificationHandler.RECEIVED_DONT:
      command = "DONT";
      break;
    case TelnetNotificationHandler.RECEIVED_WILL:
      command = "WILL";
      break;
    case TelnetNotificationHandler.RECEIVED_WONT:
      command = "WONT";
      break;
    case TelnetNotificationHandler.RECEIVED_COMMAND:
      command = "COMMAND";
      break;
    default:
      command = Integer.toString(negotiation_code); // Should not happen
      break;
  }
  System.out.println("Received " + command + " for option code " + option_code);
}
 
Example 2
Source File: SwitchTelnetClientSocket.java    From daq with Apache License 2.0 6 votes vote down vote up
/**
 * * Callback method called when TelnetClient receives an option negotiation command.
 *
 * @param negotiationCode - type of negotiation command received (RECEIVED_DO, RECEIVED_DONT,
 *                         RECEIVED_WILL, RECEIVED_WONT, RECEIVED_COMMAND)
 * @param optionCode      - code of the option negotiated *
 */
public void receivedNegotiation(int negotiationCode, int optionCode) {
  String command = null;
  switch (negotiationCode) {
    case TelnetNotificationHandler.RECEIVED_DO:
      command = "DO";
      break;
    case TelnetNotificationHandler.RECEIVED_DONT:
      command = "DONT";
      break;
    case TelnetNotificationHandler.RECEIVED_WILL:
      command = "WILL";
      break;
    case TelnetNotificationHandler.RECEIVED_WONT:
      command = "WONT";
      break;
    case TelnetNotificationHandler.RECEIVED_COMMAND:
      command = "COMMAND";
      break;
    default:
      command = Integer.toString(negotiationCode); // Should not happen
      break;
  }
  System.out.println("Received " + command + " for option code " + optionCode);
}