triptracker.client.net
Class MapSocketAdapter

java.lang.Object
  extended by triptracker.client.net.MapSocketAdapter
All Implemented Interfaces:
MapSocketListener, SocketListener
Direct Known Subclasses:
LoginForm

public abstract class MapSocketAdapter
extends Object
implements MapSocketListener

An abstract adapter class for receiving map socket events. The methods in this class are empty. This class exists as convenience for creating listener objects.

Extend this class to create a MapSocketConnection listener and override the methods for the events of interest. (If you implement the MapSocketListener interface, you have to define all of the methods in it. This abstract class defines null methods for them all, so you only have to define methods for events you care about.)

Create a listener object using the extended class and then register it with a MapSocketConnection using the socket's addListener method. When the socket's status changes, the relevant method in the listener object is invoked.


Nested Class Summary
 
Nested classes/interfaces inherited from interface triptracker.client.net.MapSocketListener
MapSocketListener.RouteState
 
Constructor Summary
MapSocketAdapter()
           
 
Method Summary
 void connectionUpdate(ConnectionState state)
          Invoked when the connection state of the underlying socket has changed.
 void coordReceived(int routeId, Coordinate coordinate)
          Invoked when a coordinate is received.
 void coordsReceived(List<Coordinate> coords)
          Invoked when buffered coordinates is received.
 void invalidMessage(String message)
          Invoked when an invalid or unsupported message is received from the server.
 void routeList(List<Route> routes)
          Invoked when a list of routes is received.
 void routeReceived(int routeId, List<Coordinate> coordinates)
          Invoked when a list of coordinates for a given route is received.
 void routeUpdate(int routeId, MapSocketListener.RouteState state)
          Invoked when the state of a route is changed.
 void socketError(IOException e)
          Invoked when a socket error is encountered.
 void userReceived(User user)
          Invoked when a rouser is received.
 void usersReceived(List<User> users)
          Invoked when a list of registered users is received.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapSocketAdapter

public MapSocketAdapter()
Method Detail

connectionUpdate

public void connectionUpdate(ConnectionState state)
Invoked when the connection state of the underlying socket has changed.

Specified by:
connectionUpdate in interface SocketListener
Parameters:
state - new connection state

invalidMessage

public void invalidMessage(String message)
Invoked when an invalid or unsupported message is received from the server. This happens when the message parser method (often SocketConnection.messageHandler(String)) fails to understand the message, or if it contains invalid data.

Specified by:
invalidMessage in interface SocketListener
Parameters:
message - the message that triggered the event

socketError

public void socketError(IOException e)
Invoked when a socket error is encountered. This generally means that the socket has been closed or at least disconnected from the server.

Specified by:
socketError in interface SocketListener
Parameters:
e - the error that triggered the event

coordReceived

public void coordReceived(int routeId,
                          Coordinate coordinate)
Invoked when a coordinate is received.

Specified by:
coordReceived in interface MapSocketListener
Parameters:
routeId - route the coordinate belongs to
coordinate - coordinate received

coordsReceived

public void coordsReceived(List<Coordinate> coords)
Invoked when buffered coordinates is received.

Specified by:
coordsReceived in interface MapSocketListener
Parameters:
coords - list of coordinates

routeList

public void routeList(List<Route> routes)
Invoked when a list of routes is received.

Specified by:
routeList in interface MapSocketListener
Parameters:
routes - list of routes

routeReceived

public void routeReceived(int routeId,
                          List<Coordinate> coordinates)
Invoked when a list of coordinates for a given route is received.

Specified by:
routeReceived in interface MapSocketListener
Parameters:
routeId - route the list of coordinates belongs to
coordinates - list of coordinates

routeUpdate

public void routeUpdate(int routeId,
                        MapSocketListener.RouteState state)
Invoked when the state of a route is changed.

Specified by:
routeUpdate in interface MapSocketListener
Parameters:
routeId - route the state change applies to
state - the new state

usersReceived

public void usersReceived(List<User> users)
Invoked when a list of registered users is received.

Specified by:
usersReceived in interface MapSocketListener
Parameters:
users - list of users

userReceived

public void userReceived(User user)
Invoked when a rouser is received.

Specified by:
userReceived in interface MapSocketListener


Copyright © 2006 Team Trip Tracker. All Rights Reserved.