KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > org > quickserver > net > server > TestEventHandler


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 test.org.quickserver.net.server;
16
17 import org.quickserver.net.server.*;
18 import java.io.*;
19 import java.net.*;
20
21 /**
22  * TestEventHandler for QuickServer
23  */

24 public class TestEventHandler implements ClientEventHandler {
25     private static volatile int gotConnectedFlag;
26     private static volatile int lostConnectionFlag;
27     private static volatile int closingConnectionFlag;
28
29     public void gotConnected(ClientHandler handler) throws SocketTimeoutException, IOException {
30         gotConnectedFlag++;
31     }
32     public void lostConnection(ClientHandler handler) throws IOException {
33         lostConnectionFlag++;
34     }
35     public void closingConnection(ClientHandler handler) throws IOException {
36         closingConnectionFlag++;
37     }
38
39     public static int getGotConnectedFlag() {
40         return gotConnectedFlag;
41     }
42     public static int getLostConnectionFlag() {
43         return lostConnectionFlag;
44     }
45     public static int getClosingConnectionFlag() {
46         return closingConnectionFlag;
47     }
48
49     public static void reset() {
50         gotConnectedFlag = 0;
51         lostConnectionFlag = 0;
52         closingConnectionFlag = 0;
53     }
54 }
55
Popular Tags