tictactoe
Class GameProxy
java.lang.Object
|
+--java.rmi.server.RemoteObject
|
+--java.rmi.server.RemoteServer
|
+--java.rmi.server.UnicastRemoteObject
|
+--tictactoe.GameProxy
- public class GameProxy
- extends java.rmi.server.UnicastRemoteObject
- implements RemoteGame
BoardGame wrapper to provide RemoteGame interface.
NB: All methods are synchronized since multiple
client threads may access the server simultaneously.
- Version:
- 3.0 1999-04-02
- Author:
- Oscar.Nierstrasz@acm.org
- See Also:
AbstractBoardGame
, Serialized Form
Fields inherited from class java.rmi.server.RemoteObject |
ref |
Method Summary |
void |
addObserver(RemoteObserver remote)
|
int |
cols()
|
char |
currentPlayer()
For remote clients. |
char |
join()
A client connected to the game must join
the game to know what its mark is (X or O). |
boolean |
move(Move move)
Attempt to move to the given square. |
boolean |
notOver()
|
boolean |
ready()
The game is ready to be played if
there are two connected clients. |
int |
rows()
|
java.lang.String |
winner()
For remote clients. |
Methods inherited from class java.rmi.server.UnicastRemoteObject |
clone,
exportObject,
exportObject,
exportObject,
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 |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
_game
protected BoardGame _game
_connected
protected int _connected
ready
public boolean ready()
throws java.rmi.RemoteException
- The game is ready to be played if
there are two connected clients.
- Specified by:
- ready in interface RemoteGame
join
public char join()
throws java.rmi.RemoteException
- A client connected to the game must join
the game to know what its mark is (X or O).
If two players are connected, further players
may connect, but only as spectators.
(This possibility is not exploited in 3.0)
- Specified by:
- join in interface RemoteGame
move
public boolean move(Move move)
throws java.rmi.RemoteException
- Attempt to move to the given square.
Called by a remote client.
We check if move.mark corresponds to the
current Player, and then call BoardGame.move().
- Specified by:
- move in interface RemoteGame
- Returns:
- true if the move is valid
- See Also:
PlaceListener.mouseClicked(java.awt.event.MouseEvent)
currentPlayer
public char currentPlayer()
throws java.rmi.RemoteException
- For remote clients.
- Specified by:
- currentPlayer in interface RemoteGame
- Returns:
- mark of current player (i.e., not the Player)
winner
public java.lang.String winner()
throws java.rmi.RemoteException
- For remote clients.
- Specified by:
- winner in interface RemoteGame
- Returns:
- the name of the winner (i.e., not the Player)
addObserver
public void addObserver(RemoteObserver remote)
throws java.rmi.RemoteException
- Specified by:
- addObserver in interface RemoteGame
cols
public int cols()
throws java.rmi.RemoteException
- Specified by:
- cols in interface RemoteGame
rows
public int rows()
throws java.rmi.RemoteException
- Specified by:
- rows in interface RemoteGame
notOver
public boolean notOver()
throws java.rmi.RemoteException
- Specified by:
- notOver in interface RemoteGame