Exemplo n.º 1
0
        public void Cluster(Cluster cluster)
        {
            if (cluster == null)
                throw new NotSupportedException("undefined cluster");

            _cluster = cluster;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        public void Uncluster()
        {
            if (_cluster == null)
                throw new NotSupportedException("already unclustered");

            _cluster = null;
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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;
        }