Merge branch 'subtree'
[nikiroo-utils.git] / serial / server / ConnectActionClientObject.java
1 package be.nikiroo.utils.serial.server;
2
3 import java.io.IOException;
4 import java.net.Socket;
5 import java.net.UnknownHostException;
6
7 import 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 */
17 public class ConnectActionClientObject extends ConnectActionClient {
18 /**
19 * Create a new {@link ConnectActionClientObject} .
20 *
21 * @param s
22 * the socket to bind to
23 * @param key
24 * an optional key to encrypt all the communications (if NULL,
25 * everything will be sent in clear text)
26 */
27 public ConnectActionClientObject(Socket s, String key) {
28 super(s, key);
29 }
30
31 /**
32 * Create a new {@link ConnectActionClientObject} .
33 *
34 * @param s
35 * the socket to bind to
36 * @param key
37 * an optional key to encrypt all the communications (if NULL,
38 * everything will be sent in clear text)
39 * @param clientVersion
40 * the version of the client
41 */
42 public ConnectActionClientObject(Socket s, String key, Version clientVersion) {
43 super(s, key, clientVersion);
44 }
45
46 /**
47 * Create a new {@link ConnectActionClientObject}.
48 *
49 * @param host
50 * the host to bind to
51 * @param port
52 * the port to bind to
53 * @param key
54 * an optional key to encrypt all the communications (if NULL,
55 * everything will be sent in clear text)
56 *
57 * @throws IOException
58 * in case of I/O error
59 * @throws UnknownHostException
60 * if the IP address of the host could not be determined
61 * @throws IllegalArgumentException
62 * if the port parameter is outside the specified range of valid
63 * port values, which is between 0 and 65535, inclusive
64 */
65 public ConnectActionClientObject(String host, int port, String key)
66 throws IOException {
67 super(host, port, key);
68 }
69
70 /**
71 * Create a new {@link ConnectActionClientObject}.
72 *
73 * @param host
74 * the host to bind to
75 * @param port
76 * the port to bind to
77 * @param key
78 * an optional key to encrypt all the communications (if NULL,
79 * everything will be sent in clear text)
80 * @param clientVersion
81 * the version of the client
82 *
83 * @throws IOException
84 * in case of I/O error
85 * @throws UnknownHostException
86 * if the IP address of the host could not be determined
87 * @throws IllegalArgumentException
88 * if the port parameter is outside the specified range of valid
89 * port values, which is between 0 and 65535, inclusive
90 */
91 public ConnectActionClientObject(String host, int port, String key,
92 Version clientVersion) throws IOException {
93 super(host, port, key, clientVersion);
94 }
95
96 /**
97 * Serialise and send the given object to the server (and return the
98 * deserialised answer).
99 *
100 * @param data
101 * the data to send
102 *
103 * @return the answer, which can be NULL
104 *
105 * @throws IOException
106 * in case of I/O error
107 * @throws NoSuchFieldException
108 * if the serialised data contains information about a field
109 * which does actually not exist in the class we know of
110 * @throws NoSuchMethodException
111 * if a class described in the serialised data cannot be created
112 * because it is not compatible with this code
113 * @throws ClassNotFoundException
114 * if a class described in the serialised data cannot be found
115 */
116 public Object send(Object data) throws IOException, NoSuchFieldException,
117 NoSuchMethodException, ClassNotFoundException {
118 return action.sendObject(data);
119 }
120
121 // Deprecated //
122
123 /**
124 * @deprecated SSL support has been replaced by key-based encryption.
125 * <p>
126 * Please use the version with key encryption (this deprecated
127 * version uses an empty key when <tt>ssl</tt> is TRUE and no
128 * key (NULL) when <tt>ssl</tt> is FALSE).
129 */
130 @Deprecated
131 public ConnectActionClientObject(String host, int port, boolean ssl)
132 throws IOException {
133 this(host, port, ssl ? "" : null);
134 }
135
136 /**
137 * @deprecated SSL support has been replaced by key-based encryption.
138 * <p>
139 * Please use the version with key encryption (this deprecated
140 * version uses an empty key when <tt>ssl</tt> is TRUE and no
141 * key (NULL) when <tt>ssl</tt> is FALSE).
142 */
143 @Deprecated
144 public ConnectActionClientObject(String host, int port, boolean ssl,
145 Version version) throws IOException {
146 this(host, port, ssl ? "" : null, version);
147 }
148
149 /**
150 * @deprecated SSL support has been replaced by key-based encryption.
151 * <p>
152 * Please use the version with key encryption (this deprecated
153 * version uses an empty key when <tt>ssl</tt> is TRUE and no
154 * key (NULL) when <tt>ssl</tt> is FALSE).
155 */
156 @SuppressWarnings("unused")
157 @Deprecated
158 public ConnectActionClientObject(Socket s, boolean ssl) throws IOException {
159 this(s, ssl ? "" : null);
160 }
161
162 /**
163 * @deprecated SSL support has been replaced by key-based encryption.
164 * <p>
165 * Please use the version with key encryption (this deprecated
166 * version uses an empty key when <tt>ssl</tt> is TRUE and no
167 * key (NULL) when <tt>ssl</tt> is FALSE).
168 */
169 @SuppressWarnings("unused")
170 @Deprecated
171 public ConnectActionClientObject(Socket s, boolean ssl, Version version)
172 throws IOException {
173 this(s, ssl ? "" : null, version);
174 }
175 }