KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > net > server > ClientBinaryHandler


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

56 public interface ClientBinaryHandler {
57
58     /**
59      * Method called every time client sends an binary data.
60      * Should be used to handle the binary data sent.
61      * @exception java.net.SocketTimeoutException if socket times out
62      * @exception java.io.IOException if io error in socket
63      */

64     public void handleBinary(ClientHandler handler, byte command[])
65         throws SocketTimeoutException JavaDoc, IOException;
66
67 }
68
Popular Tags