Merge commit '77d3a60869e7a780c6ae069e51530e1eacece5e2'
[fanfix.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 /**
7 * Class used for the server basic handling.
8 * <p>
9 * It represents a single action: a server is expected to execute one action for
10 * each client action.
11 *
12 * @author niki
13 */
14 public class ConnectActionServerString extends ConnectActionServer {
15 /**
16 * Create a new {@link ConnectActionServerString} as the server version.
17 *
18 * @param s
19 * the socket to bind to
20 * @param key
21 * an optional key to encrypt all the communications (if NULL,
22 * everything will be sent in clear text)
23 */
24 public ConnectActionServerString(Socket s, String key) {
25 super(s, key);
26 }
27
28 /**
29 * Serialise and send the given object to the client.
30 *
31 * @param data
32 * the data to send
33 *
34 * @throws IOException
35 * in case of I/O error
36 */
37 public void send(String data) throws IOException {
38 action.sendString(data);
39 }
40
41 /**
42 * (Flush the data to the client if needed and) retrieve its answer.
43 *
44 * @return the answer if it is available, or NULL if not
45 *
46 * @throws IOException
47 * in case of I/O error
48 */
49 public String rec() throws IOException {
50 return action.recString();
51 }
52 }