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 org.quickserver.net.server;
16:
17: import java.io.*;
18: import java.net.SocketTimeoutException;
19:
20: /**
21: * This interface defines the methods
22: * that should be implemented by any class that
23: * wants to handle java Objects from a client.
24: *
25: * <p>
26: * Recommendations to be followed when implementing ClientBinaryHandler
27: * <ul>
28: * <li>Should have a default constructor.
29: * <li>Should be thread safe.
30: * <li>It should not store any data that may is associated with a particular client.
31: * <li>If any client data is need to be saved from the client session,
32: * it should be saved to a {@link ClientData} class, which can be retrieved
33: * using handler.getClientData() method.
34: * </ul>
35: * </p>
36: * <p>
37: * Ex:
38: * <code><BLOCKQUOTE><pre>
39: package dateserver;
40:
41: import java.net.*;
42: import java.io.*;
43: import java.util.Date;
44: import org.quickserver.net.server.*;
45:
46: public class BinaryHandler implements ClientBinaryHandler {
47:
48: public void handleBinary(ClientHandler handler, byte command[]))
49: throws SocketTimeoutException, IOException {
50: handler.sendSystemMsg("Got Binary : " + new String(command));
51: }
52: }
53: </pre></BLOCKQUOTE></code></p>
54: * @author Akshathkumar Shetty
55: * @since 1.4
56: */
57: public interface ClientBinaryHandler {
58:
59: /**
60: * Method called every time client sends an binary data.
61: * Should be used to handle the binary data sent.
62: * @exception java.net.SocketTimeoutException if socket times out
63: * @exception java.io.IOException if io error in socket
64: */
65: public void handleBinary(ClientHandler handler, byte command[])
66: throws SocketTimeoutException, IOException;
67:
68: }
|