From f6a689cd4705b85a7efbd27aa9dafdf77c52d720 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 28 Apr 2009 17:00:10 +0000 Subject: [PATCH] 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 --- .../crowd/peer/server/CrowdPeerManager.java | 38 ++++--------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/src/java/com/threerings/crowd/peer/server/CrowdPeerManager.java b/src/java/com/threerings/crowd/peer/server/CrowdPeerManager.java index 76ad194c0..f34d727bc 100644 --- a/src/java/com/threerings/crowd/peer/server/CrowdPeerManager.java +++ b/src/java/com/threerings/crowd/peer/server/CrowdPeerManager.java @@ -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 _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;