示例#1
0
 /// <summary>
 /// Create a new instance of a host with a random ID.
 /// </summary>
 public Host()
 {
     hostInfo = new HostInfo () { Id = HostCache.RandomId () };
     status = HostStatus.NoIdentity;
     heartbeat.Elapsed += (sender, args) => {
         log.Info ("Host timed out, terminating");
         status = HostStatus.Disconnected;
         lastInter.DisconnectHost (hostInfo);
         heartbeat.Stop ();
         heartbeat.Dispose ();
     };
     NodePool.Instance.Nodes.CollectionChanged += OnGlobalNodesChange;
     _nodes = new ObservableCollection<NodeInfo> ();
     _nodes.CollectionChanged += NodesCollectionChanged;
 }
示例#2
0
 /// <summary>
 /// Disconnect the host.
 /// </summary>
 /// <param name="hostInfo"></param>
 public void DisconnectHost(HostInfo hostInfo)
 {
     foreach (var node in HostCache.FindHost(hostInfo.Id).Nodes)
         NodePool.Instance.DestroyNode(node);
     HostCache.ConnectedHosts.Remove(hostInfo.Id);
 }
示例#3
0
 /// <summary>
 /// Send a message to the host.
 /// </summary>
 /// <param name="hostInfo">Host identifier.</param>
 /// <param name="buildMessage">Message to send.</param>
 public void SendTo(HostInfo hostInfo, byte[] buildMessage)
 {
     lock (server)
     {
         server.SendMore(hostInfo.Id);
         server.Send(buildMessage);
     }
 }