au.com.solidsoftware.multimahjong.shared
Class Observer

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--au.com.solidsoftware.multimahjong.shared.Observer
Direct Known Subclasses:
GamesObserver, PlayersObserver

public class Observer
extends java.rmi.server.UnicastRemoteObject
implements ObserverIntf

The Observer acts as a connection between the Referee and the Game classes whenever the Referee needs to send information to inform the Game of a change in the situation. The Observer implements the ObserverIntf class that is required by RMI because these methods need to be called remotely during a multi player game.

Author:
Dean Cortinovis, Michael Hart
See Also:
Referee, Game, Serialized Form

Field Summary
private  Game game
          This is just a reference to the Game.
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
csf, port, portFactoryParamTypes, portParamTypes, serialVersionUID, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
log, logname, serialVersionUID
 
Fields inherited from class java.rmi.server.RemoteObject
ref, serialVersionUID
 
Constructor Summary
Observer()
          Just calls superclass constructor.
 
Method Summary
 void addGame(java.lang.String name, int limit, int playerID)
          This method is empty and is overridden by the GamesObserver .
 void addPlayer(java.lang.String name, int playerID)
          This method is empty and is overridden by the PlayersObserver .
 void exitGame()
          Gives Game the exit flag to exit the game.
 void placePlayerAction(Moves givenMove, int action, boolean exit)
          Places the current player's tile and the associated action for the Game to retrieve.
 void placeResult(int winningSelection, int currentPlayer, boolean exit)
          Inserts a winning player and their selection.
 void placeRobResult(int robbingPlayer, boolean exit)
          Places the location of the robbing player, if any.
 void removeGame(int gameID)
          This method is empty and is overridden by the GamesObserver .
 void setGame(Game game)
          Sets the local game variable.
 void updateWaiting(int gameID, int waitingToJoin)
          This method is empty and is overridden by the GamesObserver .
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
, clone, exportObject, exportObject, exportObject, exportObject, readObject, reexport, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

game

private Game game
This is just a reference to the Game.
Constructor Detail

Observer

public Observer()
         throws java.rmi.RemoteException
Just calls superclass constructor.
Method Detail

setGame

public void setGame(Game game)
             throws java.rmi.RemoteException
Sets the local game variable.
Specified by:
setGame in interface ObserverIntf

placePlayerAction

public void placePlayerAction(Moves givenMove,
                              int action,
                              boolean exit)
                       throws java.rmi.RemoteException
Places the current player's tile and the associated action for the Game to retrieve.
Specified by:
placePlayerAction in interface ObserverIntf
Parameters:
givenMove - Class containing the tile corresponding to the given action.
action - Player's selected action.
exit - Exit flag.
See Also:
Moves

placeResult

public void placeResult(int winningSelection,
                        int currentPlayer,
                        boolean exit)
                 throws java.rmi.RemoteException
Inserts a winning player and their selection.

Specified by:
placeResult in interface ObserverIntf
Parameters:
winningSelection - Players selection.
currentPlayer - The new current player.
exit - Exit flag.

placeRobResult

public void placeRobResult(int robbingPlayer,
                           boolean exit)
                    throws java.rmi.RemoteException
Places the location of the robbing player, if any.

Specified by:
placeRobResult in interface ObserverIntf
Parameters:
robbingPlayer - Player robbing the Kong (if any).
exit - Exit flag.

exitGame

public void exitGame()
              throws java.rmi.RemoteException
Gives Game the exit flag to exit the game.
Specified by:
exitGame in interface ObserverIntf

addPlayer

public void addPlayer(java.lang.String name,
                      int playerID)
               throws java.rmi.RemoteException
This method is empty and is overridden by the PlayersObserver . See PlayersObserver for details of this method.
Specified by:
addPlayer in interface ObserverIntf
See Also:
PlayersObserver

addGame

public void addGame(java.lang.String name,
                    int limit,
                    int playerID)
             throws java.rmi.RemoteException
This method is empty and is overridden by the GamesObserver . See GamesObserver for details of this method.
Specified by:
addGame in interface ObserverIntf
See Also:
GamesObserver

updateWaiting

public void updateWaiting(int gameID,
                          int waitingToJoin)
                   throws java.rmi.RemoteException
This method is empty and is overridden by the GamesObserver . See GamesObserver for details of this method.
Specified by:
updateWaiting in interface ObserverIntf
See Also:
GamesObserver

removeGame

public void removeGame(int gameID)
                throws java.rmi.RemoteException
This method is empty and is overridden by the GamesObserver . See GamesObserver for details of this method.
Specified by:
removeGame in interface ObserverIntf
See Also:
GamesObserver