public CachedDiscoveryManager(short port)
        {
            Guid                        id        = Guid.NewGuid();
            Raw                         r         = new Raw(port);
            SimpleDiscovery             sd        = new SimpleDiscovery(r);
            Dictionary <string, string> arguments = new Dictionary <string, string> ();

            arguments.Add("ID", id.ToString());
            arguments.Add("HOST", System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName);
            arguments.Add("PORT", port.ToString());
            sd.DiscoverMessageReceived += (sender, e) => {
                Guid msgID = Guid.Parse(e.Request.Arguments ["ID"]);
                if (hosts.ContainsKey(msgID))
                {
                    lock (hosts)
                        hosts.Add(msgID, e.Request);
                }
                else
                {
                    lock (hosts)
                        hosts [msgID].Arguments = e.Request.Arguments;
                }
            };
            sd.SetMessageInformation(arguments);
        }
示例#2
0
 public CachedDiscoveryManager(short port)
 {
     Guid id = Guid.NewGuid ();
     Raw r = new Raw (port);
     SimpleDiscovery sd = new SimpleDiscovery (r);
     Dictionary<string, string> arguments = new Dictionary<string, string> ();
     arguments.Add ("ID", id.ToString ());
     arguments.Add ("HOST", System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties ().DomainName);
     arguments.Add ("PORT", port.ToString ());
     sd.DiscoverMessageReceived += (sender, e) => {
         Guid msgID = Guid.Parse (e.Request.Arguments ["ID"]);
         if (hosts.ContainsKey (msgID)) {
             lock (hosts)
                 hosts.Add (msgID, e.Request);
         } else {
             lock (hosts)
                 hosts [msgID].Arguments = e.Request.Arguments;
         }
     };
     sd.SetMessageInformation (arguments);
 }