1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package triptracker.client.net;
21
22 import java.io.IOException;
23
24 import triptracker.core.ConnectionState;
25
26 /***
27 * Listener interface for a socket connection.
28 * {@link triptracker.client.net.SocketConnection#addListener} is used to
29 * register as a listener for server events and this interface specified what
30 * events can be triggered.
31 */
32 public interface SocketListener {
33 /***
34 * Invoked when an invalid or unsupported message is received from the
35 * server. This happens when the message parser method (often
36 * {@link SocketConnection#messageHandler(String)}) fails to understand
37 * the message, or if it contains invalid data.
38 *
39 * @param message the message that triggered the event
40 */
41 public void invalidMessage(String message);
42
43 /***
44 * Invoked when a socket error is encountered. This generally means that the
45 * socket has been closed or at least disconnected from the server.
46 *
47 * @param exception the error that triggered the event
48 */
49 public void socketError(IOException exception);
50
51 /***
52 * Invoked when the connection state of the underlying socket has changed.
53 *
54 * @param state new connection state
55 */
56 public void connectionUpdate(ConnectionState state);
57
58 }