View Javadoc

1   /*
2    * Trip Tracker, a real-time position tracking system for the Internet.
3    * Copyright (C) 2006  Team Trip Tracker
4    *
5    * This program is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU General Public License as published by the
7    * Free Software Foundation; either version 2 of the License, or (at your
8    * option) any later version.
9    *
10   * This program is distributed in the hope that it will be useful, but
11   * WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13   * General Public License for more details.
14   *
15   * You should have received a copy of the GNU General Public License along
16   * with this program; if not, write to the Free Software Foundation, Inc.,
17   * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18   */
19  
20  package triptracker.server;
21  
22  import java.io.IOException;
23  
24  /***
25   * Listener interface for the server and its client connections. 
26   * {@link triptracker.server.Server#addListener(ServerListener)} is used
27   * to register as a listener for server events and this interface specified
28   * what events can be triggered.
29   */
30  public interface ServerListener {
31  	/***
32  	 * Invoked when a client joins (successful authentication) or disconnects.
33  	 * 
34  	 * @param client joined or disconnected client
35  	 * @param joined true if joined, false if disconnected
36  	 */
37  	// TODO (jani) Need to separate between map and GPS clients. State chart.
38  //	public void clientListUpdate(ClientHandler client, ConnectionState state);
39  	public void clientListUpdate(ClientHandler client, boolean joined);
40  	
41  	/***
42  	 * Invoked when an invalid or unsupported message is received from the
43  	 * client. This happens when the message parser method (often
44  	 * {@link ClientHandler#messageHandler(String)}) fails to understand
45  	 * the message, or if it contains invalid data.
46  	 * 
47  	 * @param message the message that triggered the event
48  	 */
49  	public void invalidMessage(ClientHandler client, String message);
50  	
51  	/***
52  	 * Invoked when a socket error is encountered. This generally means that the
53  	 * socket for this client has been closed or at least disconnected. 
54  	 * 
55  	 * @param exception the error that triggered the event
56  	 */
57  	public void socketError(ClientHandler client, IOException exception);
58  	
59  //	public void newMessage(ClientHandler client, String message);
60  }