| org.quickserver.net.server.ClientCommandHandler
All known Subclasses: ftpserver.CommandHandler, echowebserver.EchoWSCommandHandler, test.org.quickserver.net.server.TestCommandHandler, dateserver.CommandHandler, cmdserver.CmdCommandHandler, filesrv.CommandHandler, echoserver.EchoCommandHandler, org.quickserver.net.qsadmin.CommandHandler, xmladder.CommandHandler, chatserver.ChatCommandHandler,
ClientCommandHandler | public interface ClientCommandHandler (Code) | | This interface defines the methods that should be implemented by any
class that wants to handle character/string data from client.
Recommendations to be followed when implementing ClientCommandHandler
- Should have a default constructor.
- Should be thread safe.
- It should not store any data that may is associated with a particular client.
- If any client data is need to be saved from the client session,
it should be saved to a
ClientData class, which can be retrieved
using handler.getClientData() method.
Ex:
package echoserver;
import java.net.*;
import java.io.*;
import org.quickserver.net.server.ClientCommandHandler;
import org.quickserver.net.server.ClientHandler;
public class EchoCommandHandler implements ClientCommandHandler {
public void handleCommand(ClientHandler handler, String command)
throws SocketTimeoutException, IOException {
if(command.toLowerCase().equals("quit")) {
handler.sendClientMsg("Bye ;-)");
handler.closeConnection();
} else {
handler.sendClientMsg("Echo : " + command);
}
}
}
author: Akshathkumar Shetty |
|
|