NextableInputStream: separate base behaviour from nextable
[fanfix.git] / src / be / nikiroo / utils / serial / server / ConnectActionClientObject.java
CommitLineData
79ce1a49
NR
1package be.nikiroo.utils.serial.server;
2
3import java.io.IOException;
4import java.net.Socket;
f4053377 5import java.net.UnknownHostException;
79ce1a49
NR
6
7import be.nikiroo.utils.Version;
8
9/**
10 * Class used for the client basic handling.
11 * <p>
12 * It represents a single action: a client is expected to only execute one
13 * action.
14 *
15 * @author niki
16 */
17public class ConnectActionClientObject extends ConnectActionClient {
18 /**
19 * Create a new {@link ConnectActionClientObject} with the current
20 * application version (see {@link Version#getCurrentVersion()}) as the
21 * client version.
22 *
23 * @param s
24 * the socket to bind to
8468bb79
NR
25 * @param key
26 * an optional key to encrypt all the communications (if NULL,
27 * everything will be sent in clear text)
79ce1a49 28 */
8468bb79
NR
29 public ConnectActionClientObject(Socket s, String key) {
30 super(s, key);
79ce1a49
NR
31 }
32
33 /**
34 * Create a new {@link ConnectActionClientObject} with the current
35 * application version (see {@link Version#getCurrentVersion()}) as the
36 * client version.
37 *
38 * @param host
39 * the host to bind to
40 * @param port
41 * the port to bind to
8468bb79
NR
42 * @param key
43 * an optional key to encrypt all the communications (if NULL,
44 * everything will be sent in clear text)
79ce1a49
NR
45 *
46 * @throws IOException
f4053377
NR
47 * in case of I/O error
48 * @throws UnknownHostException
49 * if the IP address of the host could not be determined
50 * @throws IllegalArgumentException
51 * if the port parameter is outside the specified range of valid
52 * port values, which is between 0 and 65535, inclusive
79ce1a49 53 */
8468bb79 54 public ConnectActionClientObject(String host, int port, String key)
79ce1a49 55 throws IOException {
8468bb79 56 super(host, port, key);
79ce1a49
NR
57 }
58
59 /**
60 * Create a new {@link ConnectActionClientObject}.
61 *
62 * @param host
63 * the host to bind to
64 * @param port
65 * the port to bind to
8468bb79
NR
66 * @param key
67 * an optional key to encrypt all the communications (if NULL,
68 * everything will be sent in clear text)
79ce1a49
NR
69 * @param version
70 * the client version
71 *
72 * @throws IOException
f4053377
NR
73 * in case of I/O error
74 * @throws UnknownHostException
75 * if the IP address of the host could not be determined
76 * @throws IllegalArgumentException
77 * if the port parameter is outside the specified range of valid
78 * port values, which is between 0 and 65535, inclusive
79ce1a49 79 */
8468bb79 80 public ConnectActionClientObject(String host, int port, String key,
79ce1a49 81 Version version) throws IOException {
8468bb79 82 super(host, port, key, version);
79ce1a49
NR
83 }
84
85 /**
86 * Create a new {@link ConnectActionClientObject}.
87 *
88 * @param s
89 * the socket to bind to
90 * @param version
91 * the client version
8468bb79
NR
92 * @param key
93 * an optional key to encrypt all the communications (if NULL,
94 * everything will be sent in clear text)
79ce1a49 95 */
8468bb79
NR
96 public ConnectActionClientObject(Socket s, String key, Version version) {
97 super(s, key, version);
79ce1a49
NR
98 }
99
100 /**
101 * Serialise and send the given object to the server (and return the
102 * deserialised answer).
103 *
104 * @param data
105 * the data to send
106 *
107 * @return the answer, which can be NULL
108 *
109 * @throws IOException
110 * in case of I/O error
111 * @throws NoSuchFieldException
112 * if the serialised data contains information about a field
113 * which does actually not exist in the class we know of
114 * @throws NoSuchMethodException
115 * if a class described in the serialised data cannot be created
116 * because it is not compatible with this code
117 * @throws ClassNotFoundException
118 * if a class described in the serialised data cannot be found
119 */
120 public Object send(Object data) throws IOException, NoSuchFieldException,
121 NoSuchMethodException, ClassNotFoundException {
122 return action.sendObject(data);
123 }
124}