public interface ClientExtendedEventHandler
Recommendations to be followed when implementing ClientExtendedEventHandler
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;
}
}
}
Modifier and Type | Method and Description |
---|---|
void |
handleMaxAuthTry(ClientHandler handler)
Method called when client has reached maximum auth tries.
|
boolean |
handleMaxConnection(ClientHandler handler)
Method called when maximum number of clients has been reached and
a new client connects.
|
void |
handleTimeout(ClientHandler handler)
Method called when client timeouts.
|
void handleTimeout(ClientHandler handler) throws java.net.SocketException, java.io.IOException
java.net.SocketException
- if client socket needs to be closed.java.io.IOException
- if io error in socketvoid handleMaxAuthTry(ClientHandler handler) throws java.io.IOException
java.io.IOException
- if io error in socketboolean handleMaxConnection(ClientHandler handler) throws java.io.IOException
true
the
client is accepted else client connection is closed.java.io.IOException
- if io error in socketCopyright © 2003-2014 QuickServer.org