Пример #1
0
        public bool ClusterBadge(Clusterable badge, Cluster cluster)
        {
            if (badge.IsInCluster())
            {
                //two or more clients sent clustering requests in the same time. first wins
                Log.Warn("cluster failed: badge=" + badge.GetId() + " cluster=" + cluster.GetId() +
                         " current cluster of badge=" + badge.GetCluster().GetId());
                return(false);
            }

            badge.Cluster(cluster);
            cluster.Add(badge);
            return(true);
        }
Пример #2
0
        //badge is deleted (not moved out of cluster)
        public void DeleteBadge(Clusterable deleted, int usrId)
        {
            //1 remove all links
            UnlinkFromAll(deleted, -1);

            //2 remove from cluster, if it's in cluster
            UnclusterBadge(deleted, -1);

            //3 remove badge itself
            _badges.Remove(deleted.GetId());
            if (onLinkableDeleted != null)
            {
                onLinkableDeleted(deleted, usrId);
            }
        }
Пример #3
0
        private void __unclusterBadge(Clusterable badge, Cluster cluster, int userId)
        {
            _room.BroadcastReliableToRoom((byte)DiscussionEventCode.UnclusterBadgeEvent,
                                          UnclusterBadgeMessage.Write(
                                              badge.GetId(),
                                              cluster.GetId(),
                                              true, _topicId, userId, -1));

            EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr),
                                        _room,
                                        StEvent.ClusterOut,
                                        userId,
                                        _topicId);
            _pendingChanges = true;
        }
Пример #4
0
        public void UnclusterBadge(Clusterable badge, int usrId)
        {
            if (!badge.IsInCluster())
            {
                Log.Warn("badge " + badge.GetId() + " is already unclustered");
                return;
            }

            //1 remove from cluster
            var affectedCluster = badge.GetCluster();

            affectedCluster.Remove(badge);
            badge.Uncluster();
            if (onUnclusterBadge != null)
            {
                onUnclusterBadge(badge, affectedCluster, usrId);
            }

            //2 if cluster is empty, delete cluster
            if (affectedCluster.IsEmpty())
            {
                DeleteCluster(affectedCluster, usrId);
            }
        }
Пример #5
0
        public bool ClusterBadge(Clusterable badge, Cluster cluster)
        {
            if (badge.IsInCluster())
            {
                //two or more clients sent clustering requests in the same time. first wins
                Log.Warn("cluster failed: badge=" + badge.GetId() + " cluster=" + cluster.GetId() +
                          " current cluster of badge=" + badge.GetCluster().GetId());
                return false;
            }

            badge.Cluster(cluster);
            cluster.Add(badge);
            return true;
        }
Пример #6
0
        public void UnclusterBadge(Clusterable badge, int usrId)
        {
            if (!badge.IsInCluster())
            {
                Log.Warn("badge " + badge.GetId() + " is already unclustered");
                return;
            }

            //1 remove from cluster            
            var affectedCluster = badge.GetCluster();
            affectedCluster.Remove(badge);
            badge.Uncluster();
            if (onUnclusterBadge != null)
                onUnclusterBadge(badge, affectedCluster, usrId);

            //2 if cluster is empty, delete cluster
            if (affectedCluster.IsEmpty())
            {
                DeleteCluster(affectedCluster, usrId);
            }
        }
Пример #7
0
        //badge is deleted (not moved out of cluster)  
        public void DeleteBadge(Clusterable deleted, int usrId)
        {
            //1 remove all links 
            UnlinkFromAll(deleted, -1);

            //2 remove from cluster, if it's in cluster
            UnclusterBadge(deleted, -1);

            //3 remove badge itself
            _badges.Remove(deleted.GetId());
            if (onLinkableDeleted != null)
                onLinkableDeleted(deleted, usrId);
        }
Пример #8
0
 public void Remove(Clusterable badge)
 {
     _badges.Remove(badge);
 }
Пример #9
0
 public void Add(Clusterable badge)
 {
     _badges.Add(badge);
 }
Пример #10
0
 public void Remove(Clusterable badge)
 {
     _badges.Remove(badge);
 }
Пример #11
0
 public void Add(Clusterable badge)
 {
     _badges.Add(badge);
 }
Пример #12
0
        private void __unclusterBadge(Clusterable badge, Cluster cluster, int userId)
        {
            _room.BroadcastReliableToRoom((byte) DiscussionEventCode.UnclusterBadgeEvent,
                                          UnclusterBadgeMessage.Write(
                                              badge.GetId(),
                                              cluster.GetId(),
                                              true, _topicId, userId, -1));

            EventLogger.LogAndBroadcast(new DiscCtx(Discussions.ConfigManager.ConnStr),
                                        _room,
                                        StEvent.ClusterOut,
                                        userId,
                                        _topicId);
            _pendingChanges = true;
        }