org.apache.commons.net.telnet.TelnetNotificationHandler Java Examples
The following examples show how to use
org.apache.commons.net.telnet.TelnetNotificationHandler.
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 |
/** * * 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 |
/** * * 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); }
Example #3
Source File: TelnetHandlerTest.java From termd with Apache License 2.0 | 6 votes |
@Test public void testWillUnknownOption() throws Exception { server.start(new Supplier<TelnetHandler>() { @Override public TelnetHandler get() { return new TelnetHandler(); } }); client.registerNotifHandler(new BiConsumer<Integer, Integer>() { @Override public void accept(Integer negotiation_code, Integer option_code) { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code); testComplete(); } } }); client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false)); client.connect("localhost", 4000); await(); }
Example #4
Source File: TelnetHandlerTest.java From termd with Apache License 2.0 | 6 votes |
@Test public void testDoUnknownOption() throws Exception { server.start(new Supplier<TelnetHandler>() { @Override public TelnetHandler get() { return new TelnetHandler(); } }); client.registerNotifHandler(new BiConsumer<Integer, Integer>() { @Override public void accept(Integer negotiation_code, Integer option_code) { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code); testComplete(); } } }); client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false)); client.connect("localhost", 4000); await(); }
Example #5
Source File: TelnetClientRule.java From termd with Apache License 2.0 | 5 votes |
public TelnetClientRule registerNotifHandler(final BiConsumer<Integer, Integer> handler) { checkNotConnected(); client.registerNotifHandler(new TelnetNotificationHandler() { @Override public void receivedNegotiation(int i, int i1) { handler.accept(i, i1); } }); return this; }
Example #6
Source File: TelnetHandlerTest.java From aesh-readline with Apache License 2.0 | 5 votes |
@Test public void testWillUnknownOption() throws Exception { server.start(TelnetHandler::new); client.registerNotifHandler((negotiation_code, option_code) -> { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code); testComplete(); } }); client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false)); client.connect("localhost", 4000); await(); }
Example #7
Source File: TelnetHandlerTest.java From aesh-readline with Apache License 2.0 | 5 votes |
@Test public void testDoUnknownOption() throws Exception { server.start(TelnetHandler::new); client.registerNotifHandler((negotiation_code, option_code) -> { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code); testComplete(); } }); client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false)); client.connect("localhost", 4000); await(); }
Example #8
Source File: TelnetHandlerTest.java From termd with Apache License 2.0 | 5 votes |
@Test public void testWillUnknownOption() throws Exception { server.start(TelnetHandler::new); client.registerNotifHandler((negotiation_code, option_code) -> { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_DONT, negotiation_code); testComplete(); } }); client.setOptionHandler(new SimpleOptionHandler(47, true, false, false, false)); client.connect("localhost", 4000); await(); }
Example #9
Source File: TelnetHandlerTest.java From termd with Apache License 2.0 | 5 votes |
@Test public void testDoUnknownOption() throws Exception { server.start(TelnetHandler::new); client.registerNotifHandler((negotiation_code, option_code) -> { if (option_code == 47) { assertEquals(TelnetNotificationHandler.RECEIVED_WONT, negotiation_code); testComplete(); } }); client.setOptionHandler(new SimpleOptionHandler(47, false, true, false, false)); client.connect("localhost", 4000); await(); }