コード例 #1
0
        ///// <summary>
        ///// Sends a single (non-periodic) message to the specified IP address to see if it supports the
        ///// specified port mapping protocol, and begin listening indefinitely for responses.
        ///// </summary>
        ///// <param name="gatewayAddress">The IP address</param>
        ///// <param name="type"></param>
        //public void Search (IPAddress gatewayAddress, NatProtocol type)
        //{
        //	lock (Locker) {
        //		if (type == NatProtocol.Pmp) {
        //			PmpSearcher.Instance.SearchAsync (gatewayAddress).FireAndForget ();
        //		} else if (type == NatProtocol.Upnp) {
        //			UpnpSearcher.Instance.SearchAsync (gatewayAddress).FireAndForget ();
        //		} else {
        //			throw new InvalidOperationException ("Unsuported type given");
        //		}
        //	}
        //}

        /// <summary>
        /// Periodically send a multicast UDP message to scan for new devices, and begin listening indefinitely
        /// for responses.
        /// </summary>
        //  public void StartDiscovery(params NatProtocol [] devices)
        //	{
        //	}

        /// <summary>
        /// Stop listening for responses to the search messages, and cancel any pending searches.
        /// </summary>
        public void Dispose()
        {
            if (_pmpSearcher != null)
            {
                _pmpSearcher.Dispose();
                _pmpSearcher = null;
            }
            if (_upnpSearcher != null)
            {
                _upnpSearcher.Dispose();
                _upnpSearcher = null;
            }
        }