au.com.solidsoftware.multimahjong.shared
Class RemoteReferee
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--au.com.solidsoftware.multimahjong.shared.Referee
|
+--au.com.solidsoftware.multimahjong.shared.RemoteReferee
- public class RemoteReferee
- extends Referee
RemoteReferee extends Referee and provides extra functionality
for adding players and starting the game remotely (ie from the MMC). It
contains a PlayersObserver that it receives when it is created
and it contacts this class whenever a new player is added to the game. It
also creates a StartGameSynch object that acts as the mutual
exclusive lock when players who have joined are waiting for the game to
start.
- Author:
- Michael Hart
- See Also:
Referee,
PlayersObserver,
StartGameSynch, Serialized Form
|
Field Summary |
private StartGameSynch |
gameStarter
This provides the RemoteReferee with an object to
synchronize with when starting the game. |
private ObserverIntf |
playersObserver
This is a reference to the PlayersObserver that is passed in
when this class is instantiated. |
| Fields inherited from class au.com.solidsoftware.multimahjong.shared.Referee |
game,
gameWall,
limit,
MAX_CLIENTS,
noOfClients,
player,
players,
positions,
received,
robSelection,
selection,
selectionsMade,
serverInitialised,
wall |
| 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 |
RemoteReferee(java.lang.String name,
int limit,
int iconID,
ObserverIntf playersObserver)
Sets up the superclass Referee, sets the local
playersObserver variable and instantiates a new
StartGameSynch class. |
|
Method Summary |
int |
addPlayer(ObserverIntf observer,
java.lang.String name,
int iconID)
Adds a new player to the game. |
Referee |
startGame()
Calls the startGame method in the local
StartGameSynch object. |
Referee |
waitForStart()
Calls the waitForStart method in the local
StartGameSynch object. |
| Methods inherited from class au.com.solidsoftware.multimahjong.shared.Referee |
beginGame,
determineRobKong,
exitGame,
getLimit,
getPlayers,
getPos,
getPositions,
getWall,
initServer,
placePlayerAction,
placeSelection |
| 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 |
playersObserver
private ObserverIntf playersObserver
- This is a reference to the
PlayersObserver that is passed in
when this class is instantiated.
gameStarter
private StartGameSynch gameStarter
- This provides the
RemoteReferee with an object to
synchronize with when starting the game.
RemoteReferee
public RemoteReferee(java.lang.String name,
int limit,
int iconID,
ObserverIntf playersObserver)
throws java.rmi.RemoteException
- Sets up the superclass
Referee, sets the local
playersObserver variable and instantiates a new
StartGameSynch class.
- Parameters:
name - the name of the creator of the gamelimit - the limit of the gameiconID - the icon ID of the creator of the gameplayersObserver - the Observer to contact with new
information- See Also:
Referee,
StartGameSynch,
PlayersObserver,
ObserverIntf
addPlayer
public int addPlayer(ObserverIntf observer,
java.lang.String name,
int iconID)
throws java.rmi.RemoteException
- Adds a new player to the game. Calls the same method in the superclass
Referee after checking that the maximum number of clients
has not been reached. It then tries to notify the PlayersObserver
that a new player has been added to their game.
- Parameters:
observer - the Observer with which to contact this new
player withname - the name of the new playericonID - the icon ID of the new player- Returns:
- the player ID returned by the superclass method
- Overrides:
- addPlayer in class Referee
- See Also:
Referee,
PlayersObserver,
ObserverIntf
startGame
public Referee startGame()
throws java.rmi.RemoteException
- Calls the
startGame method in the local
StartGameSynch object.
- Parameters:
gameID - the game that is about to be started- Returns:
- whatever
StartGameSynch.startGame returns - See Also:
StartGameSynch,
StartGameSynch.waitForStart(),
Referee
waitForStart
public Referee waitForStart()
throws java.rmi.RemoteException
- Calls the
waitForStart method in the local
StartGameSynch object.
- Parameters:
gameID - the game that is waiting to be started- Returns:
- whatever
RemoteReferee.waitForStart
returns - See Also:
StartGameSynch,
StartGameSynch.waitForStart(),
Referee