Inheritance: ISearcher
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 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);
        }