1 /***
2 * Jetrix TetriNET Server
3 * Copyright (C) 2001-2004 Emmanuel Bourg
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 package net.jetrix;
21
22 import java.io.*;
23 import java.net.*;
24 import java.util.*;
25
26 /***
27 * Layer handling communication with a client. Incomming messages are turned
28 * into a server understandable format and forwarded to the apropriate
29 * destination for processing (player's channel or main server thread)
30 *
31 * @author Emmanuel Bourg
32 * @version $Revision: 857 $, $Date: 2010-05-04 19:55:19 +0200 (mar., 04 mai 2010) $
33 */
34 public interface Client extends Runnable, Destination
35 {
36 /***
37 * Return the protocol used by this client.
38 */
39 Protocol getProtocol();
40
41 /***
42 * Return the channel this client subscribed to.
43 */
44 Channel getChannel();
45
46 /***
47 * Set the channel.
48 */
49 void setChannel(Channel channel);
50
51 /***
52 * Tell if the client supports multiple channels simultaneously.
53 *
54 * @since 0.2
55 */
56 boolean supportsMultipleChannels();
57
58 /***
59 * Tell if the client can be affected automatically to a channel
60 * on connecting to the server.
61 *
62 * @since 0.2
63 */
64 boolean supportsAutoJoin();
65
66 /***
67 * Return the user associated to this client.
68 */
69 User getUser();
70
71 /***
72 * Returns the name of the user agent (GTetrinet, aTwin, Blocktrix...)
73 *
74 * @since 0.3
75 */
76 String getAgent();
77
78 /***
79 * Return the version of the user agent (1.13, 1.14, etc)
80 */
81 String getVersion();
82
83 /***
84 * Return the Internet address of this client.
85 */
86 InetAddress getInetAddress();
87
88 /***
89 * Return the time of the connection to the server.
90 */
91 Date getConnectionTime();
92
93 /***
94 * Return the time in miliseconds of inactivity.
95 *
96 * @since 0.2
97 */
98 long getIdleTime();
99
100 /***
101 * Returns the character encoding to be used for the messages sent to the client.
102 *
103 * @since 0.3
104 */
105 String getEncoding();
106
107 /***
108 * Send a message to the client. The raw message property must be set.
109 *
110 * @param message the message to send
111 */
112 void send(Message message);
113
114 /***
115 * Receive a message sent by the client.
116 *
117 * @since 0.3
118 */
119 Message receive() throws IOException;
120
121 /***
122 * Trigger the disconnection of this client.
123 */
124 void disconnect();
125
126 }