Inheritance: ISearcher
Example #1
0
        public Task Handle(IPAddress localAddress, UpnpDeviceInfo deviceInfo, IPEndPoint endpoint, NatProtocol protocol)
        {
            switch (protocol)
            {
            case NatProtocol.Upnp:
                var searcher = new UpnpSearcher(Logger, HttpClient);
                searcher.DeviceFound += Searcher_DeviceFound;
                return(searcher.Handle(localAddress, deviceInfo, endpoint));

            default:
                throw new ArgumentException("Unexpected protocol: " + protocol);
            }
        }
Example #2
0
        public static async Task Handle(IPAddress localAddress, UpnpDeviceInfo deviceInfo, IPEndPoint endpoint, NatProtocol protocol)
        {
            switch (protocol)
            {
            case NatProtocol.Upnp:
                var searcher = new UpnpSearcher(Logger, HttpClient);
                searcher.DeviceFound += Searcher_DeviceFound;
                await searcher.Handle(localAddress, deviceInfo, endpoint).ConfigureAwait(false);

                break;

            default:
                throw new ArgumentException("Unexpected protocol: " + protocol);
            }
        }
Example #3
0
 private static INatDevice GetDevice(CancellationToken cancellation)
 {
     UpnpSearcher searcher = new UpnpSearcher();
     var device = searcher.SearchAndReceive(cancellation);
     if(device == null)
     {
         NodeServerTrace.Information("No UPnP device found");
         return null;
     }
     return device;
 }
Example #4
0
        static ISearcher GetOrCreate(NatProtocol protocol)
        {
            if (!Searchers.TryGetValue(protocol, out ISearcher searcher))
            {
                searcher                     = protocol == NatProtocol.Pmp ? (ISearcher)PmpSearcher.Create() : UpnpSearcher.Create();
                searcher.DeviceFound        += HandleDeviceFound;
                searcher.UnknownDeviceFound += HandleUnknownDeviceFound;
                Searchers[protocol]          = searcher;
            }

            return(searcher);
        }