...
[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 * @param key
25 * an optional key to encrypt all the communications (if NULL,
26 * everything will be sent in clear text)
27 */
28 public ConnectActionServerString(Socket s, String key) {
29 super(s, key);
30 }
31
32 /**
33 * Serialise and send the given object to the client.
34 *
35 * @param data
36 * the data to send
37 *
38 * @throws IOException
39 * in case of I/O error
40 */
41 public void send(String data) throws IOException {
42 action.sendString(data);
43 }
44
45 /**
46 * (Flush the data to the client if needed and) retrieve its answer.
47 *
48 * @return the answer if it is available, or NULL if not
49 *
50 * @throws IOException
51 * in case of I/O error
52 */
53 public String rec() throws IOException {
54 return action.recString();
55 }
56 }