public void LeaveNode(string NID, NetPeer peer) { List <InterestNode> nodes = this.Nodes; lock (nodes) { InterestNode node = nodes.SingleOrDefault(n => n.NodeID == NID); if (node != null) { node.UnSubscribe(peer); } } }
public bool JoinNode(string NID, NetPeer peer) { List <InterestNode> nodes = this.Nodes; lock (nodes) { InterestNode node = nodes.SingleOrDefault(n => n.NodeID == NID); if (node == null) { InterestNode item = new InterestNode(NID); this.Nodes.Add(item); item.Subscribe(peer); return(false); } node.Subscribe(peer); return(true); } }
// Methods public int GetNode(string NID) { InterestNode item = Nodes.SingleOrDefault(n => n.NodeID == NID); return((item != null) ? this.Nodes.IndexOf(item) : -1); }