public interface ITelnetCommandHandler
//-- Add the logmaster command handler.
iTelnetCommandHandler lh = new iTelnetCommandHandler()
{
public boolean executeTelnetCommand(TelnetPrintWriter tpw, CmdStringDecoder commandline) throws Exception
{
return MyClass.executeTelnetCommand(tpw, commandline);
}
};
LogMaster.registerTelnetCommand(lh);
The telnet command handler returns TRUE if it has executed the command and false if not. For all entered commands ALL handlers are ALWAYS called, so you must take care NOT to report an error if you do not recognise a command. If a command is NOT recognised by any registered handler an error message is output to the issuing session. A typical implementation of a command handler would be:
static protected boolean executeTelnetCommand(TelnetPrintWriter ts, CmdStringDecoder cmd) throws Exception
{
if(cmd.currIs("?")) // Help command (global)?
{
ts.println(USAGE);
return true;
}
if(! cmd.currIs("myclass")) return false; // all my commands start with myclass
if(! cmd.hasMore() || cmd.currIs("?")) // myclass ? is my usage exclusively.
{
ts.println(USAGE);
return true;
}
else if(cmd.currIs("fil*")) // myclass file?
{
.... handle this command....
}
return false; // Unrecognised!
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
executeTelnetCommand(TelnetPrintWriter tpw,
CmdStringDecoder commandline) |
boolean executeTelnetCommand(TelnetPrintWriter tpw, CmdStringDecoder commandline) throws Exception
ExceptionCopyright © 2017 etc.to. All rights reserved.