public interface ClientCommandHandler
Recommendations to be followed when implementing ClientCommandHandler
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);
}
}
}
Modifier and Type | Method and Description |
---|---|
void |
handleCommand(ClientHandler handler,
java.lang.String command)
Method called every time client sends character/string data.
|
void handleCommand(ClientHandler handler, java.lang.String command) throws java.net.SocketTimeoutException, java.io.IOException
java.net.SocketTimeoutException
- if socket times outjava.io.IOException
- if io error in socketCopyright © 2003-2014 QuickServer.org