Merge commit 'b459e462a5c3447d0693674253c40bc7385a4f66'
[fanfix.git] / serial / server / ConnectActionServerString.java
CommitLineData
79ce1a49
NR
1package be.nikiroo.utils.serial.server;
2
3import java.io.IOException;
4import java.net.Socket;
5
79ce1a49
NR
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 */
14public class ConnectActionServerString extends ConnectActionServer {
15 /**
340e6065 16 * Create a new {@link ConnectActionServerString} as the server version.
79ce1a49
NR
17 *
18 * @param s
19 * the socket to bind to
8468bb79
NR
20 * @param key
21 * an optional key to encrypt all the communications (if NULL,
22 * everything will be sent in clear text)
79ce1a49 23 */
8468bb79
NR
24 public ConnectActionServerString(Socket s, String key) {
25 super(s, key);
79ce1a49
NR
26 }
27
79ce1a49
NR
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}