Global Positioning System Reference
In-Depth Information
Note that the actual implementation LCPlayer.init(GameSet) is acces-
sible for extending players. It can be overridden (don't forget super.init )
to get a reference to the gameset for fancy computations. This is especially
important for graphical front ends to get precise geographical coordinates
for drawing. A simple player does not need to deal with it and can leave
it covered (not overridden).
The next remote method after init
public int getRole() { return LCPlayer.this.role; }
is completely hidden to the extending player, since it does not access
a method, only a member of the outer class. The role has to be cho-
sen at construction time for the total runtime just like the identity in
ServerObject.getIdentity() (which could be subject to change with a
deeper identity check). This solution reduces the network trac.
At this point, the basic mechanisms and initial methods for the client
server dialog are implemented and the game developer can add more game
methods.
Now it is time to connect the player to the game server. For an exclusive
LC implementation, the server connection could be established with the
player construction. In the ROAF context, the RO clients can exist on
their own to enter and leave ROApps as they choose. Therefore, the client
can be hooked to the server in three steps, which enables the implementing
player to explicitly decide when to take those steps. Note that the remote
application is private and inaccessible for the player implementation.
The client first has to look up the server application with
final protected static boolean
lookupROApp( String host, int port, String name )
{
...
rmiURL = "rmi://" + host + ":" + port + "/" + name;
roApp = (RemoteObjectsApplication)
RMI.lookupRMIURL( rmiURL );
...
}
and then the player can invoke identify on the server:
final protected boolean identifyPlayer()
{
... roApp.identify( this.client );
}
The server responds by calling back the client with .init(gameSet) . Note
that the keyword this always refers to the full implementation of an in-
stantiated object. It does not and can not refer to the base class only.
Therefore, the method does not need to specify the actual implementation
of the LCPlayer .
 
Search WWH ::




Custom Search