1 package be
.nikiroo
.utils
.serial
.server
;
3 import java
.io
.IOException
;
4 import java
.net
.Socket
;
6 import be
.nikiroo
.utils
.Version
;
9 * Class used for the server basic handling.
11 * It represents a single action: a server is expected to execute one action for
16 public class ConnectActionServerObject
extends ConnectActionServer
{
18 * Create a new {@link ConnectActionServerObject} with the current
19 * application version (see {@link Version#getCurrentVersion()}) as the
23 * the socket to bind to
25 * an optional key to encrypt all the communications (if NULL,
26 * everything will be sent in clear text)
28 public ConnectActionServerObject(Socket s
, String key
) {
33 * Serialise and send the given object to the client.
39 * in case of I/O error
40 * @throws NoSuchFieldException
41 * if the serialised data contains information about a field
42 * which does actually not exist in the class we know of
43 * @throws NoSuchMethodException
44 * if a class described in the serialised data cannot be created
45 * because it is not compatible with this code
46 * @throws ClassNotFoundException
47 * if a class described in the serialised data cannot be found
49 public void send(Object data
) throws IOException
, NoSuchFieldException
,
50 NoSuchMethodException
, ClassNotFoundException
{
51 action
.sendObject(data
);
55 * (Flush the data to the client if needed and) retrieve its answer.
57 * @return the deserialised answer (which can actually be NULL)
60 * in case of I/O error
61 * @throws NoSuchFieldException
62 * if the serialised data contains information about a field
63 * which does actually not exist in the class we know of
64 * @throws NoSuchMethodException
65 * if a class described in the serialised data cannot be created
66 * because it is not compatible with this code
67 * @throws ClassNotFoundException
68 * if a class described in the serialised data cannot be found
69 * @throws java.lang.NullPointerException
70 * if the counter part has no data to send
72 public Object
rec() throws NoSuchFieldException
, NoSuchMethodException
,
73 ClassNotFoundException
, IOException
, java
.lang
.NullPointerException
{
74 return action
.recObject();