Ray points out a flaw in our vizname to authname approach:

1. User logs onto node 1, node 2 establishes a viztoauth mapping.
2. User logs onto node 3 without logging out of 1, overwriting their
session.
3. Node 2 sees "member logged onto 3" and updates the viztoauth mapping.
4. Node 2 sees "member logged off of 2" and clears the viztoauth mapping.
5. Viola, there is no active viztoauth mapping, but user is online.

Distributed programming is hard. Fortunately on Whirled we can convert any
vizname to an authname without needing a mapping, so we'll just foist that
requirement onto every user of the crowd peer services (this will break Bang).


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5755 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2009-04-28 17:00:10 +00:00
parent d65dc84d1b
commit f6a689cd47
@@ -21,9 +21,6 @@
package com.threerings.crowd.peer.server;
import java.util.Map;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.threerings.util.Name;
@@ -48,7 +45,7 @@ import com.threerings.crowd.peer.data.CrowdNodeObject;
/**
* Extends the standard peer manager and bridges certain Crowd services.
*/
public class CrowdPeerManager extends PeerManager
public abstract class CrowdPeerManager extends PeerManager
implements CrowdPeerProvider, ChatProvider.ChatForwarder
{
/**
@@ -81,7 +78,7 @@ public class CrowdPeerManager extends PeerManager
ChatService.TellListener listener)
{
// look up their auth username from their visible name
Name username = _viztoauth.get(target);
Name username = authFromViz(target);
if (username == null) {
return false; // sorry kid, don't know ya
}
@@ -160,32 +157,11 @@ public class CrowdPeerManager extends PeerManager
_chatprov.setChatForwarder(this);
}
@Override // from PeerManager
protected void clientLoggedOn (String nodeName, ClientInfo clinfo)
{
super.clientLoggedOn(nodeName, clinfo);
// keep a mapping from visibleName to auth username
if (clinfo instanceof CrowdClientInfo) {
CrowdClientInfo ccinfo = (CrowdClientInfo)clinfo;
_viztoauth.put(ccinfo.visibleName, ccinfo.username);
}
}
@Override // from PeerManager
protected void clientLoggedOff (String nodeName, ClientInfo clinfo)
{
super.clientLoggedOff(nodeName, clinfo);
// update our mapping from visibleName to auth username
if (clinfo instanceof CrowdClientInfo) {
CrowdClientInfo ccinfo = (CrowdClientInfo)clinfo;
_viztoauth.remove(ccinfo.visibleName);
}
}
/** A mapping of visible name to username for all clients on all *remote* nodes. */
protected Map<Name, Name> _viztoauth = Maps.newHashMap();
/**
* Converts a visible name to an authentication name. If this method returns null, the chat
* system will act as if the vizname in question is not online.
*/
protected abstract Name authFromViz (Name vizname);
@Inject protected InvocationManager _invmgr;
@Inject protected ChatProvider _chatprov;