All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class game.ServerHandler

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----game.Handler
                   |
                   +----game.ServerHandler

public class ServerHandler
extends Handler
The ServerHandler class handles the server connection in the client. [DESCRIBE ME MORE]


Variable Index

 o address
DNS name of the server we're dealing with (or IP address)
 o BIG_CHANGE
 o changeData
 o changeStatus
 o gameInfos
Vector containing GameInfos about the games the server can provide.
 o INFO_ADDED
 o INFO_CHANGED
 o INFO_REMOVED
 o name
Name of the server (retrieved from the server itself)
 o NO_CHANGE
 o port
Port number of the server
 o version
Version of the server

Constructor Index

 o ServerHandler(Socket, String, int)
Creates a new ServerHandler.

Method Index

 o clearChanged()
 o countGames()
Returns the number of games available from this server
 o doCreateGame(LinkFrame)
Handles the ST_CREATE_GAME message.
 o doGameRemoved(LinkFrame)
Handles the ST_GAME_REMOVED message.
 o doInfoChanged(LinkFrame)
Handles the ST_INFO_CHANGED message.
 o frameReceived(Object, LinkFrame)
Messaged when a new data frame is received by the GameLink object and this frame belongs to the groups the GameLinkListener asked to listen to.
 o getChangeInfo()
 o getChangeInfos()
 o getChangeStatus()
Returns the last change status of this handler.
 o getGameInfo(Object)
Returns the GameInfo corresponding to the given Id.
 o getGameInfos()
Returns all GameInfo available from this server.
 o getServerAddress()
Returns the host name or IP address of the server we're connected to
 o getServerName()
Returns the name of the server we're connected to
 o getServerPort()
Returns the port of the server we're connected to
 o removeGameInfo(Object)
Removes from the game infos set the GameInfo corresponding to the given Id.
 o run()
Starts this server handler.
 o setChangeData(Object)
 o setChangeStatus(int)
 o toString()
Returns a string representation of the object.

Variables

 o address
 String address
DNS name of the server we're dealing with (or IP address)

 o name
 String name
Name of the server (retrieved from the server itself)

 o port
 int port
Port number of the server

 o version
 int version
Version of the server

 o gameInfos
 Vector gameInfos
Vector containing GameInfos about the games the server can provide.

 o changeData
 Object changeData
 o changeStatus
 int changeStatus
 o NO_CHANGE
 public static final int NO_CHANGE
 o BIG_CHANGE
 public static final int BIG_CHANGE
 o INFO_CHANGED
 public static final int INFO_CHANGED
 o INFO_ADDED
 public static final int INFO_ADDED
 o INFO_REMOVED
 public static final int INFO_REMOVED

Constructors

 o ServerHandler
 public ServerHandler(Socket socket,
                      String address,
                      int port) throws SocketException
Creates a new ServerHandler.

Parameters:
socket - the socket connected to the server.
address - name or IP address of the server.
port - the port the server listens to.

Methods

 o run
 public void run()
Starts this server handler. This methods keeps on executing until the connection with server is lost, so it should be run in a separate thread.

Overrides:
run in class Thread
 o getServerAddress
 public String getServerAddress()
Returns the host name or IP address of the server we're connected to

 o getServerName
 public String getServerName()
Returns the name of the server we're connected to

 o getServerPort
 public int getServerPort()
Returns the port of the server we're connected to

 o countGames
 public int countGames()
Returns the number of games available from this server

 o getGameInfo
 public GameInfo getGameInfo(Object id)
Returns the GameInfo corresponding to the given Id.

Parameters:
id - the id used to search for the GameInfo
Returns:
the corresponding GameInfo
 o getGameInfos
 public Enumeration getGameInfos()
Returns all GameInfo available from this server.

 o removeGameInfo
 public void removeGameInfo(Object id)
Removes from the game infos set the GameInfo corresponding to the given Id. In this very particular case, id may be a regular game id OR a GameInfo object.

Parameters:
id - the id of the game to be removed from the client.
 o toString
 public String toString()
Returns a string representation of the object.

Overrides:
toString in class Thread
 o frameReceived
 public void frameReceived(Object link,
                           LinkFrame frame)
Messaged when a new data frame is received by the GameLink object and this frame belongs to the groups the GameLinkListener asked to listen to.

Parameters:
frame - the frame that has just been received.
Overrides:
frameReceived in class Handler
See Also:
GameLink
 o doInfoChanged
 public void doInfoChanged(LinkFrame frame)
Handles the ST_INFO_CHANGED message.

Parameters:
frame - the frame containing the ST_INFO_CHANGED message.
 o doGameRemoved
 public void doGameRemoved(LinkFrame frame)
Handles the ST_GAME_REMOVED message.

Parameters:
frame - the frame containing the ST_GAME_REMOVED message.
 o doCreateGame
 public void doCreateGame(LinkFrame frame)
Handles the ST_CREATE_GAME message. Actually instantiates the client game class and start the client game.

Parameters:
frame - the frame containing the ST_CREATE_GAME message.
 o getChangeStatus
 public int getChangeStatus()
Returns the last change status of this handler.

 o setChangeStatus
 void setChangeStatus(int status)
 o clearChanged
 public void clearChanged()
 o setChangeData
 void setChangeData(Object data)
 o getChangeInfos
 public Enumeration getChangeInfos()
 o getChangeInfo
 public GameInfo getChangeInfo()

All Packages  Class Hierarchy  This Package  Previous  Next  Index