예제 #1
0
        public override async Task DeletePortMapAsync(Mapping mapping)
        {
            Guard.IsNotNull(mapping, "mapping");

            if (mapping.PrivateIP.Equals(IPAddress.None))
            {
                mapping.PrivateIP = DeviceInfo.LocalAddress;
            }

            NatDiscoverer.TraceSource.LogInfo("DeletePortMapAsync - Deleteing port mapping {0}", mapping);

            try
            {
                var message = new DeletePortMappingRequestMessage(mapping);
                await _soapClient
                .InvokeAsync("DeletePortMapping", message.ToXml())
                .TimeoutAfter(TimeSpan.FromSeconds(4));

                UnregisterMapping(mapping);
            }
            catch (MappingException e)
            {
                if (e.ErrorCode != UpnpConstants.NoSuchEntryInArray)
                {
                    throw;
                }
            }
        }
예제 #2
0
        public override Task DeletePortMapAsync(Mapping mapping)
        {
            Guard.IsNotNull(mapping, "mapping");

            if (mapping.PrivateIP.Equals(IPAddress.None))
            {
                mapping.PrivateIP = DeviceInfo.LocalAddress;
            }

            NatDiscoverer.TraceSource.LogInfo("DeletePortMapAsync - Deleteing port mapping {0}", mapping);

            var message = new DeletePortMappingRequestMessage(mapping);

            return(_soapClient
                   .InvokeAsync("DeletePortMapping", message.ToXml())
                   .TimeoutAfter(TimeSpan.FromSeconds(4))
                   .ContinueWith(task =>
            {
                if (!task.IsFaulted)
                {
                    UnregisterMapping(mapping);
                }
                else
                {
                    MappingException e = task.Exception.InnerException as MappingException;
                    if (e != null && e.ErrorCode != UpnpConstants.NoSuchEntryInArray)
                    {
                        throw e;
                    }
                }
            }));
        }
예제 #3
0
        public override async Task DeletePortMapAsync(Mapping mapping)
        {
            Guard.IsNotNull(mapping, "mapping");

            try
            {
                var message = new DeletePortMappingRequestMessage(mapping);
                await _soapClient
                .InvokeAsync("DeletePortMapping", message.ToXml())
                .TimeoutAfter(TimeSpan.FromSeconds(4));

                UnregisterMapping(mapping);
            }
            catch (MappingException e)
            {
                if (e.ErrorCode != UpnpConstants.NoSuchEntryInArray)
                {
                    throw;
                }
            }
        }
예제 #4
0
		public override async Task DeletePortMapAsync(Mapping mapping)
		{
            Guard.IsNotNull(mapping, "mapping");

            if (mapping.PrivateIP.Equals(IPAddress.None)) mapping.PrivateIP = DeviceInfo.LocalAddress;
            
            NatDiscoverer.TraceSource.LogInfo("DeletePortMapAsync - Deleteing port mapping {0}", mapping);

            try
		    {
                var message = new DeletePortMappingRequestMessage(mapping);
                await _soapClient
                    .InvokeAsync("DeletePortMapping", message.ToXml())
                    .TimeoutAfter(TimeSpan.FromSeconds(4));
                UnregisterMapping(mapping);
            }
		    catch (MappingException e)
		    {
                if(e.ErrorCode != UpnpConstants.NoSuchEntryInArray) throw; 
		    }
        }
예제 #5
0
		public override async Task DeletePortMapAsync(Mapping mapping)
		{
            Guard.IsNotNull(mapping, "mapping");

            try
		    {
                var message = new DeletePortMappingRequestMessage(mapping);
                await _soapClient
                    .InvokeAsync("DeletePortMapping", message.ToXml())
                    .TimeoutAfter(TimeSpan.FromSeconds(4));
                UnregisterMapping(mapping);
            }
		    catch (MappingException e)
		    {
                if(e.ErrorCode != UpnpConstants.NoSuchEntryInArray) throw; 
		    }
        }
예제 #6
0
        public override Task DeletePortMapAsync(Mapping mapping)
        {
            Guard.IsNotNull(mapping, "mapping");

            if (mapping.PrivateIP.Equals(IPAddress.None)) mapping.PrivateIP = DeviceInfo.LocalAddress;

            NatDiscoverer.TraceSource.LogInfo("DeletePortMapAsync - Deleteing port mapping {0}", mapping);

            var message = new DeletePortMappingRequestMessage(mapping);
            return _soapClient
                .InvokeAsync("DeletePortMapping", message.ToXml())
                .TimeoutAfter(TimeSpan.FromSeconds(4))
                .ContinueWith(task =>
                {
                    if (!task.IsFaulted)
                    {
                        UnregisterMapping(mapping);
                    }
                    else
                    {
                        MappingException e = task.Exception.InnerException as MappingException;
                        if (e != null && e.ErrorCode != UpnpConstants.NoSuchEntryInArray) throw e;
                    }
                });
        }