35dd4dd1985fb810c8300d4a810f16f227efd5a8
[nikiroo-utils.git] / src / be / nikiroo / utils / serial / server / ConnectActionServerString.java
1 package be.nikiroo.utils.serial.server;
2
3 import java.io.IOException;
4 import java.net.Socket;
5
6 import 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 */
16 public 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
24 */
25 public ConnectActionServerString(Socket s) {
26 super(s);
27 }
28
29 /**
30 * Create a new {@link ConnectActionServerString}.
31 *
32 * @param s
33 * the socket to bind to
34 * @param version
35 * the server version
36 */
37 public ConnectActionServerString(Socket s, Version version) {
38 super(s, version);
39 }
40
41 /**
42 * Serialise and send the given object to the client.
43 *
44 * @param data
45 * the data to send
46 *
47 * @throws IOException
48 * in case of I/O error
49 */
50 public void send(String data) throws IOException {
51 action.sendString(data);
52 }
53
54 /**
55 * (Flush the data to the client if needed and) retrieve its answer.
56 *
57 * @return the answer if it is available, or NULL if not
58 *
59 * @throws IOException
60 * in case of I/O error
61 */
62 public String rec() throws IOException {
63 return action.recString();
64 }
65 }