Separate the reporting of session end to observers from clearing out our
internal bits. Only report that a session ended if we reported that it started, but always clear out our bits when a session is shutting down. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5659 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -39,6 +39,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
|
|
||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
|
import com.threerings.presents.annotation.EventThread;
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
import com.threerings.presents.net.AuthRequest;
|
import com.threerings.presents.net.AuthRequest;
|
||||||
import com.threerings.presents.net.AuthResponse;
|
import com.threerings.presents.net.AuthResponse;
|
||||||
@@ -449,9 +450,9 @@ public class ClientManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the client instance when it has started its session. This is called from the
|
* Called by PresentsSession when it has started its session.
|
||||||
* dobjmgr thread.
|
|
||||||
*/
|
*/
|
||||||
|
@EventThread
|
||||||
protected void clientSessionDidStart (final PresentsSession client)
|
protected void clientSessionDidStart (final PresentsSession client)
|
||||||
{
|
{
|
||||||
// let the observers know
|
// let the observers know
|
||||||
@@ -464,10 +465,25 @@ public class ClientManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the client instance when the client requests a logoff. This is called from the
|
* Called by PresentsSession when it has ended its session.
|
||||||
* dobjmgr thread.
|
|
||||||
*/
|
*/
|
||||||
|
@EventThread
|
||||||
protected void clientSessionDidEnd (final PresentsSession session)
|
protected void clientSessionDidEnd (final PresentsSession session)
|
||||||
|
{
|
||||||
|
// notify the observers that the session is ended
|
||||||
|
_clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() {
|
||||||
|
public boolean apply (ClientObserver observer) {
|
||||||
|
observer.clientSessionDidEnd(session);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by PresentsSession to let us know that we can clear it entirely out of the system.
|
||||||
|
*/
|
||||||
|
@EventThread
|
||||||
|
protected void clearSession (PresentsSession session)
|
||||||
{
|
{
|
||||||
// remove the client from the username map
|
// remove the client from the username map
|
||||||
Name username = session.getCredentials().getUsername();
|
Name username = session.getCredentials().getUsername();
|
||||||
@@ -479,22 +495,12 @@ public class ClientManager
|
|||||||
|
|
||||||
// sanity check just because we can
|
// sanity check just because we can
|
||||||
if (rc == null) {
|
if (rc == null) {
|
||||||
log.info("Ending session: unregistered!", "session", session);
|
log.info("Cleared session: unregistered!", "session", session);
|
||||||
|
|
||||||
} else if (rc != session) {
|
} else if (rc != session) {
|
||||||
log.info("Ending session: multiple!", "s1", rc, "s2", session);
|
log.info("Cleared session: multiple!", "s1", rc, "s2", session);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
log.info("Ending session", "session", session);
|
log.info("Cleared session", "session", session);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify the observers that the session is ended
|
|
||||||
_clobservers.apply(new ObserverList.ObserverOp<ClientObserver>() {
|
|
||||||
public boolean apply (ClientObserver observer) {
|
|
||||||
observer.clientSessionDidEnd(session);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -338,10 +338,14 @@ public class PresentsSession
|
|||||||
|
|
||||||
// release (and destroy) our client object
|
// release (and destroy) our client object
|
||||||
_clmgr.releaseClientObject(_username);
|
_clmgr.releaseClientObject(_username);
|
||||||
|
|
||||||
|
// we only report that our session started if we managed to resolve our client object,
|
||||||
|
// so we only report that it ended in the same circumstance
|
||||||
|
_clmgr.clientSessionDidEnd(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// let the client manager know that we're audi 5000
|
// we always want to clear ourselves out of the client manager
|
||||||
_clmgr.clientSessionDidEnd(this);
|
_clmgr.clearSession(this);
|
||||||
|
|
||||||
// clear out the client object so that we know the session is over
|
// clear out the client object so that we know the session is over
|
||||||
_clobj = null;
|
_clobj = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user