| This interface defines the methods that should be implemented by any
class that wants to handle extended client events.
Recommendations to be followed when implementing ClientExtendedEventHandler
- 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.ClientExtendedEventHandler;
import org.quickserver.net.server.ClientHandler;
public class EchoExtendedEventHandler implements ClientExtendedEventHandler {
public void handleTimeout(ClientHandler handler)
throws SocketException, IOException {
handler.sendClientMsg("-ERR Timeout");
if(true) throw new SocketException();
}
public void handleMaxAuthTry(ClientHandler handler) throws IOException {
handler.sendClientMsg("-ERR Max Auth Try Reached");
}
public boolean handleMaxConnection(ClientHandler handler) throws IOException {
//for now lets reject all excess clients
if(true) {
handler.sendClientMsg("Server Busy - Max Connection Reached");
return false;
}
}
}
since: 1.4.6 author: Akshathkumar Shetty |