01: /*
02: * This file is part of the QuickServer library
03: * Copyright (C) 2003-2005 QuickServer.org
04: *
05: * Use, modification, copying and distribution of this software is subject to
06: * the terms and conditions of the GNU Lesser General Public License.
07: * You should have received a copy of the GNU LGP License along with this
08: * library; if not, you can download a copy from <http://www.quickserver.org/>.
09: *
10: * For questions, suggestions, bug-reports, enhancement-requests etc.
11: * visit http://www.quickserver.org
12: *
13: */
14:
15: package pipeserver;
16:
17: import java.net.*;
18: import java.io.*;
19: import java.util.StringTokenizer;
20: import org.quickserver.net.server.ClientEventHandler;
21: import org.quickserver.net.server.ClientBinaryHandler;
22: import org.quickserver.net.server.ClientHandler;
23: import org.quickserver.net.server.DataMode;
24: import org.quickserver.net.server.DataType;
25: import java.util.logging.*;
26:
27: public class CommandHandler implements ClientEventHandler,
28: ClientBinaryHandler {
29: private static Logger logger = Logger
30: .getLogger(CommandHandler.class.getName());
31:
32: public void gotConnected(ClientHandler handler)
33: throws SocketTimeoutException, IOException {
34: logger.fine("Connection opened: " + handler.getHostAddress());
35: /*
36: //will pick form xml
37: handler.setDataMode(DataMode.BINARY, DataType.IN);
38: handler.setDataMode(DataMode.BINARY, DataType.OUT);
39: */
40: }
41:
42: public void lostConnection(ClientHandler handler)
43: throws IOException {
44: Data data = (Data) handler.getClientData();
45: data.setClosed(true);
46: data.preclean();
47: logger.fine("Connection lost: " + handler.getHostAddress());
48: }
49:
50: public void closingConnection(ClientHandler handler)
51: throws IOException {
52: Data data = (Data) handler.getClientData();
53: data.setClosed(true);
54: data.preclean();
55: logger.fine("Connection closed: " + handler.getHostAddress());
56: }
57:
58: public void handleBinary(ClientHandler handler, byte command[])
59: throws SocketTimeoutException, IOException {
60: Data data = (Data) handler.getClientData();
61: data.sendData(command);
62: }
63: }
|