예제 #1
0
        private void OnBeaconReady(object sender, NetMQBeaconEventArgs e)
        {
            // we got another beacon
            // let's check if we already know about the beacon
            var message = _beacon.Receive();
            var port    = int.Parse(message.String);
            var node    = new NodeKey(message.PeerHost, port);

            // check if node already exist
            if (!_nodes.ContainsKey(node))
            {
                // we have a new node, let's add it and connect to subscriber
                _nodes.Add(node, DateTime.UtcNow);
                _publisher.Connect(node.Address);
                _shim.SendMoreFrame(TaskSchedulerBusCommands.AddedNode.ToString()).SendFrame(node.Address);
            }
            else
            {
                _nodes[node] = DateTime.UtcNow; //heartbeat
            }
        }
 /// <summary>
 /// Returns true if the input matches this instance
 /// </summary>
 /// <param name="other">The other instance.</param>
 /// <returns></returns>
 protected bool Equals(NodeKey other)
 {
     return(string.Equals(Name, other.Name) && Port == other.Port);
 }