private void OnBeaconReady(object sender, NetMQBeaconEventArgs e) { // we got another beacon // let's check if we already know about the beacon string nodeName; int port = Convert.ToInt32(m_beacon.ReceiveString(out nodeName)); // remove the port from the peer name nodeName = nodeName.Replace(":" + m_broadcastPort, ""); NodeKey node = new NodeKey(nodeName, port); // check if node already exist if (!m_nodes.ContainsKey(node)) { // we have a new node, let's add it and connect to subscriber m_nodes.Add(node, DateTime.Now); m_publisher.Connect(node.Address); m_shim.SendMoreFrame(AddedNodeCommand).SendFrame(node.Address); } else { //Console.WriteLine("Node {0} is not a new beacon.", node); m_nodes[node] = DateTime.Now; } }
private void OnBeaconReady(object sender, NetMQBeaconEventArgs e) { // we got another beacon // let's check if we already know about the beacon var message = m_beacon.Receive(); int port; int.TryParse(message.String, out port); NodeKey node = new NodeKey(message.PeerHost, port); // check if node already exist if (!m_nodes.ContainsKey(node)) { // we have a new node, let's add it and connect to subscriber m_nodes.Add(node, DateTime.Now); m_publisher.Connect(node.Address); m_shim.SendMoreFrame(AddedNodeCommand).SendFrame(node.Address); } else { //Console.WriteLine("Node {0} is not a new beacon.", node); m_nodes[node] = DateTime.Now; } }