Example #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);
        }
Example #2
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;
        }
Example #3
0
        public void DeleteCluster(Cluster cluster, int usrId)
        {
            //1 unlink from all
            UnlinkFromAll(cluster, -1);

            //2 remove all clusterables from cluster
            foreach (var badge in cluster.GetClusterables().ToArray())
            {
                UnclusterBadge(badge, -1);
            }

            //3 remove cluster
            _clusters.Remove(cluster.GetId());
            if (onLinkableDeleted != null)
            {
                onLinkableDeleted(cluster, usrId);
            }
        }
Example #4
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;
        }
Example #5
0
        public void DeleteCluster(Cluster cluster, int usrId)
        {
            //1 unlink from all
            UnlinkFromAll(cluster, -1);

            //2 remove all clusterables from cluster 
            foreach (var badge in cluster.GetClusterables().ToArray())
                UnclusterBadge(badge, -1);

            //3 remove cluster
            _clusters.Remove(cluster.GetId());
            if (onLinkableDeleted != null)
                onLinkableDeleted(cluster, usrId);
        }
Example #6
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;
        }