Exemple #1
0
        public bool IsPeerLogin(ulong key)
        {
            PeerContext peerContext = GetPeerContext(key);

            if (null == peerContext)
            {
                return(false);
            }

            return(peerContext.IsLogin);
        }
Exemple #2
0
        public PeerContext GetPeerContext(ulong key)
        {
            PeerContext peerContext = null;

            lock (_syncRootPeer)
            {
                if (this.PeerContexts.ContainsKey(key))
                {
                    peerContext = this.PeerContexts[key];
                }
            }

            return(peerContext);
        }
Exemple #3
0
        public void RemovePeer(ulong key, out PeerContext removedPeerContext, out UserContext removedUserContext)
        {
            removedPeerContext = null;
            removedUserContext = null;
            var peerContext = GetPeerContext(key);

            if (null == peerContext)
            {
                return;
            }

            peerContext.IsLogin.SetValue(false);

            var userContext = GetUserContext(key);

            if (null == userContext)
            {
                return;
            }

            RemoveRelation(userContext.UID, key);
            userContext.RefCount--;

            lock (_syncRootUser)
            {
                this.PeerContexts.Remove(key);
                _userContexts.Remove(key);
            }

            if (0 == userContext.RefCount)
            {
                RemoveUser(userContext.UID);
            }

            removedPeerContext = peerContext;
            removedUserContext = userContext;
        }