Merge commit '77d3a60869e7a780c6ae069e51530e1eacece5e2'
[fanfix.git] / src / be / nikiroo / utils / serial / server / ConnectActionClientString.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 ConnectActionClientString extends ConnectActionClient {
18 /**
19 * Create a new {@link ConnectActionClientString}.
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 ConnectActionClientString(Socket s, String key) {
28 super(s, key);
29 }
30
31 /**
32 * Create a new {@link ConnectActionClientString}.
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 this client
41 */
42 public ConnectActionClientString(Socket s, String key, Version clientVersion) {
43 super(s, key, clientVersion);
44 }
45
46 /**
47 * Create a new {@link ConnectActionClientString}.
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 ConnectActionClientString(String host, int port, String key)
66 throws IOException {
67 super(host, port, key);
68 }
69
70 /**
71 * Create a new {@link ConnectActionClientString}.
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 this 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 ConnectActionClientString(String host, int port, String key,
92 Version clientVersion) throws IOException {
93 super(host, port, key, clientVersion);
94 }
95
96 /**
97 * Send the given object to the server (and return the answer).
98 *
99 * @param data
100 * the data to send
101 *
102 * @return the answer, which can be NULL
103 *
104 * @throws IOException
105 * in case of I/O error
106 */
107 public String send(String data) throws IOException {
108 return action.sendString(data);
109 }
110
111 // Deprecated //
112
113 /**
114 * @deprecated SSL support has been replaced by key-based encryption.
115 * <p>
116 * Please use the version with key encryption (this deprecated
117 * version uses an empty key when <tt>ssl</tt> is TRUE and no
118 * key (NULL) when <tt>ssl</tt> is FALSE).
119 */
120 @Deprecated
121 public ConnectActionClientString(String host, int port, boolean ssl)
122 throws IOException {
123 this(host, port, ssl ? "" : null);
124 }
125
126 /**
127 * @deprecated SSL support has been replaced by key-based encryption.
128 * <p>
129 * Please use the version with key encryption (this deprecated
130 * version uses an empty key when <tt>ssl</tt> is TRUE and no
131 * key (NULL) when <tt>ssl</tt> is FALSE).
132 */
133 @Deprecated
134 public ConnectActionClientString(String host, int port, boolean ssl,
135 Version version) throws IOException {
136 this(host, port, ssl ? "" : null, version);
137 }
138
139 /**
140 * @deprecated SSL support has been replaced by key-based encryption.
141 * <p>
142 * Please use the version with key encryption (this deprecated
143 * version uses an empty key when <tt>ssl</tt> is TRUE and no
144 * key (NULL) when <tt>ssl</tt> is FALSE).
145 */
146 @SuppressWarnings("unused")
147 @Deprecated
148 public ConnectActionClientString(Socket s, boolean ssl) throws IOException {
149 this(s, ssl ? "" : null);
150 }
151
152 /**
153 * @deprecated SSL support has been replaced by key-based encryption.
154 * <p>
155 * Please use the version with key encryption (this deprecated
156 * version uses an empty key when <tt>ssl</tt> is TRUE and no
157 * key (NULL) when <tt>ssl</tt> is FALSE).
158 */
159 @SuppressWarnings("unused")
160 @Deprecated
161 public ConnectActionClientString(Socket s, boolean ssl, Version version)
162 throws IOException {
163 this(s, ssl ? "" : null, version);
164 }
165 }