KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > echoserver > EchoExtendedEventHandler


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package echoserver;
16
17 import java.net.*;
18 import java.io.*;
19 import org.quickserver.net.server.ClientExtendedEventHandler;
20 import org.quickserver.net.server.ClientHandler;
21 import java.util.logging.*;
22
23 public class EchoExtendedEventHandler implements ClientExtendedEventHandler {
24     private static Logger logger =
25             Logger.getLogger(EchoExtendedEventHandler.class.getName());
26
27     public void handleTimeout(ClientHandler handler)
28             throws SocketException, IOException {
29         handler.sendClientMsg("-ERR Timeout");
30         if(true) throw new SocketException();
31     }
32
33     public void handleMaxAuthTry(ClientHandler handler) throws IOException {
34         handler.sendClientMsg("-ERR Max Auth Try Reached");
35     }
36
37     public boolean handleMaxConnection(ClientHandler handler) throws IOException {
38         //for now lets reject all excess clients
39
if(true) {
40             handler.sendClientMsg("Server Busy - Max Connection Reached");
41             return false;
42         }
43         return true;
44     }
45 }
Popular Tags