public void RemoveMap()
        {
            if (device == null)
            {
                return;
            }

            logger.Info("UPnP attempting to remove port map(" + map.Protocol + "/" + map.Port + ")");
            device.BeginDeletePortMap(map, EndRemoveMap, map);
        }
Exemplo n.º 2
0
 private void EndRemoveTcpMap(IAsyncResult result)
 {
     try
     {
         INatDevice device = (INatDevice)result.AsyncState;
         device.EndDeletePortMap(result);
         logger.Info("UPnP successfully removed port map {0}", tcpMapping);
         device.BeginDeletePortMap(udpMapping, EndRemoveUdpMap, device);
     }
     catch (MappingException e)
     {
         logger.Error("UPnP failed to remove map port {0}. Error: {1}", tcpMapping, e);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Deletes an existing port map.
        /// </summary>
        /// <param name="port">The port to delete.</param>
        public void DeletePortMap(int port)
        {
            if (!DiscoveryCompleted)
            {
                return;
            }

            if (_mappings.TryGetValue(port, out var mapping))
            {
                try
                {
                    _device.BeginDeletePortMap(mapping, EndDeleteAsync, mapping);
                }
                catch (MappingException)
                {
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Deletes an existing port map.
        /// </summary>
        /// <param name="port">The port to delete.</param>
        public static void DeletePortMap(int port)
        {
            if (!_discoveryComplete)
            {
                return;
            }

            Mapping mapping;

            if (_mappings.TryGetValue(port, out mapping))
            {
                try
                {
                    for (int i = 0; i < 3; i++)
                    {
                        _device.BeginDeletePortMap(mapping, EndDeleteAsync, null);
                    }
                }
                catch (MappingException)
                {
                }
            }
        }