Global Positioning System Reference
In-Depth Information
To get the remote clients identity, the concept is applied inside the SO and
overrides the platonic RO method. First, the remote method to call the
remote client is implemented and externally hidden as private:
private RemoteMethod<Object> getIdentity
= new RemoteMethod<Object>()
{ @Override
public Object call() throws RemoteException
{ return remoteObject.getIdentity(); }
};
Then, the actual method can be published with
final public Object getIdentity()
{
RemoteCall<Object>
remoteCall = new RemoteCall<Object>( getID );
Object remoteID = null;
try { remoteID =
remoteCall.get( maxWaitForRemoteObject );
//
validate remote value ...
}
catch (TimeoutException e) {
//
create fallback value ...
//
remoteID = fallback;
}
//
log ...
return remoteID;
}
The RemoteMethod implementation can be created inside the method on the
fly (inline) or, separately, as above. The latter has slower performance, but
can be convenient if the remote method needs to be called with parameters.
Both strategies have access to the environment (i.e., the ROServer class).
The /*TODOs*/ in the RemoteCall listing can be filled in step by step,
when testing the code. The primary concern is the handling of Remote
Exception , which indicates that something is wrong with the client-server
connection. The server can be informed asynchronously, while the sce-
nario should continue with a plausible fallback value. From there on, the
server logic can decide what should happen, for example, stop the game in
progress, if a minimum number of players is required.
Client server propagation: report2client,report2server . When the
server logic requires a RO position, the SO has to retrieve this information
remotely and propagate it to the application process; vice versa the SO
informs the RO of server events.
The method invoked on the server should be void to indicate a dead
end. Although no value is returned, the programmer can place a number
of internal methods for asynchronous actions on the running application.
 
Search WWH ::




Custom Search