QuickServer
v1.4.7

org.quickserver.net.server
Interface ClientExtendedEventHandler


public interface ClientExtendedEventHandler

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

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

Method Summary
 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.
 

Method Detail

handleTimeout

public void handleTimeout(ClientHandler handler)
                   throws java.net.SocketException,
                          java.io.IOException
Method called when client timeouts.

Throws:
java.net.SocketException - if client socket needs to be closed.
java.io.IOException - if io error in socket

handleMaxAuthTry

public void handleMaxAuthTry(ClientHandler handler)
                      throws java.io.IOException
Method called when client has reached maximum auth tries. After this method call QuickServer will close the clients socket. Should be used to give error information to the client.

Throws:
java.io.IOException - if io error in socket

handleMaxConnection

public boolean handleMaxConnection(ClientHandler handler)
                            throws java.io.IOException
Method called when maximum number of clients has been reached and a new client connects. If this method return true the client is accepted else client connection is closed.

Throws:
java.io.IOException - if io error in socket

QuickServer
v1.4.7

Copyright © 2003-2006 QuickServer.org