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); } }
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); } }