serial: switch from SSL to CryptUtils
[nikiroo-utils.git] / src / be / nikiroo / utils / serial / server / ConnectActionServerString.java
CommitLineData
79ce1a49
NR
1package be.nikiroo.utils.serial.server;
2
3import java.io.IOException;
4import java.net.Socket;
5
6import be.nikiroo.utils.Version;
7
8/**
9 * Class used for the server basic handling.
10 * <p>
11 * It represents a single action: a server is expected to execute one action for
12 * each client action.
13 *
14 * @author niki
15 */
16public class ConnectActionServerString extends ConnectActionServer {
17 /**
18 * Create a new {@link ConnectActionServerString} with the current
19 * application version (see {@link Version#getCurrentVersion()}) as the
20 * server version.
21 *
22 * @param s
23 * the socket to bind to
8468bb79
NR
24 * @param key
25 * an optional key to encrypt all the communications (if NULL,
26 * everything will be sent in clear text)
79ce1a49 27 */
8468bb79
NR
28 public ConnectActionServerString(Socket s, String key) {
29 super(s, key);
79ce1a49
NR
30 }
31
32 /**
33 * Create a new {@link ConnectActionServerString}.
34 *
35 * @param s
36 * the socket to bind to
8468bb79
NR
37 * @param key
38 * an optional key to encrypt all the communications (if NULL,
39 * everything will be sent in clear text)
79ce1a49
NR
40 * @param version
41 * the server version
42 */
8468bb79
NR
43 public ConnectActionServerString(Socket s, String key, Version version) {
44 super(s, key, version);
79ce1a49
NR
45 }
46
47 /**
48 * Serialise and send the given object to the client.
49 *
50 * @param data
51 * the data to send
52 *
53 * @throws IOException
54 * in case of I/O error
55 */
56 public void send(String data) throws IOException {
57 action.sendString(data);
58 }
59
60 /**
61 * (Flush the data to the client if needed and) retrieve its answer.
62 *
63 * @return the answer if it is available, or NULL if not
64 *
65 * @throws IOException
66 * in case of I/O error
67 */
68 public String rec() throws IOException {
69 return action.recString();
70 }
71}