protected void handleClientObjectChanged ( int newCloid ) { // subscribe to the new client object _omgr . subscribeToObject ( newCloid , new Subscriber < ClientObject > ( ) { public void objectAvailable ( ClientObject clobj ) { // grab a reference to our old receiver registrations DSet < Registration > receivers = _clobj . receivers ; // replace the client object _clobj = clobj ; // add ourselves as an event listener _clobj . addListener ( InvocationDirector . this ) ; // reregister our receivers _clobj . startTransaction ( ) ; try { _clobj . setReceivers ( new DSet < Registration > ( ) ) ; for ( Registration reg : receivers ) { _clobj . addToReceivers ( reg ) ; } } finally { _clobj . commitTransaction ( ) ; } // and report the switcheroo back to the client _client . clientObjectDidChange ( _clobj ) ; } public void requestFailed ( int oid , ObjectAccessException cause ) { log . warning ( "Aiya! Unable to subscribe to changed client object" , "cloid" , oid , "cause" , cause ) ; } } ) ; }
Called when the server has informed us that our previous client object is going the way of the Dodo because we re changing screen names . We subscribe to the new object and report to the client once we ve got our hands on it .