Example #1
0
 public void OnServiceFound(NsdServiceInfo serviceInfo)
 {
     if (serviceInfo.ServiceName.ToLower().Equals("_lora_server"))
     {
         networkDiscovery.result = serviceInfo;
         Console.WriteLine("Found service " + serviceInfo.ServiceName);
     }
 }
Example #2
0
 public void OnServiceLost(NsdServiceInfo serviceInfo)
 {
     //if (serviceInfo.ServiceName.ToLower().Equals("_lora_server"))
     //{
     networkDiscovery.result = null;
     Console.WriteLine("Lost service " + serviceInfo.ServiceName);
     //}
 }
        public void ServiceResolved(NsdServiceInfo info)
        {
            if (createdInterfaces.Keys.Contains(info))
            {
                Logger.Info("Skipping registration of service at {0}:{1} since already registerd", info.Host, info.Port);
                return;
            }
            Logger.Info("A new ethernet interface was found at {0}:{1}", info.Host, info.Port);
            SmartScopeInterfaceEthernet ethif = null;

            try
            {
                ethif = new SmartScopeInterfaceEthernet(
                    new System.Net.IPAddress(info.Host.GetAddress()), info.Port, OnInterfaceDisconnect);
                if (ethif.Connected)
                {
                    createdInterfaces.Add(info, ethif);
                    if (onConnect != null)
                    {
                        onConnect(ethif, true);
                    }
                }
                else
                {
                    LabNation.Common.Logger.Info("... but could not connect to ethernet interface");
                }
            }
            catch (Exception e) {
                Logger.Error("Failed to handle new ethernet scope {0}:{1}", e.GetType(), e.Message);
                if (ethif != null)
                {
                    if (createdInterfaces.ContainsKey(info))
                    {
                        createdInterfaces.Remove(info);
                        if (onConnect != null)
                        {
                            onConnect(ethif, false);
                        }
                    }
                }
            }
        }
 public void OnResolveFailed(NsdServiceInfo arg0, NsdFailure fail)
 {
     Logger.Info("Service registration failed: " + fail);
 }
 public void OnServiceResolved(NsdServiceInfo info)
 {
     mServiceName = info.ServiceName;
     Logger.Debug("Service registered: " + mServiceName);
     InterfaceManagerServiceDiscovery.Instance.ServiceResolved(info);
 }