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); }
//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); } }
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; }
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); } }
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; }
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); } }
//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); }
public void Remove(Clusterable badge) { _badges.Remove(badge); }
public void Add(Clusterable badge) { _badges.Add(badge); }
public void Remove(Clusterable badge) { _badges.Remove(badge); }
public void Add(Clusterable badge) { _badges.Add(badge); }
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; }