Example usage for org.apache.commons.net.telnet TelnetNotificationHandler RECEIVED_COMMAND

List of usage examples for org.apache.commons.net.telnet TelnetNotificationHandler RECEIVED_COMMAND

Introduction

In this page you can find the example usage for org.apache.commons.net.telnet TelnetNotificationHandler RECEIVED_COMMAND.

Prototype

int RECEIVED_COMMAND

To view the source code for org.apache.commons.net.telnet TelnetNotificationHandler RECEIVED_COMMAND.

Click Source Link

Document

The remote party sent a COMMAND.

Usage

From source file:correospingtelnet.Telnet.java

/***
 * Callback method called when TelnetClient receives an option
 * negotiation command.//from   w  ww. ja  v a  2  s  .  co m
 *
 * @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
 ***/
@Override
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);
}