コード例 #1
0
        /// <summary>
        /// Begins an async call to get the external ip address of the router
        /// </summary>
        public override IAsyncResult BeginGetExternalIP(AsyncCallback callback, object asyncState)
        {
            // Create the port map message
            GetExternalIPAddressMessage message = new GetExternalIPAddressMessage(this);

            return(BeginMessageInternal(message, callback, asyncState, EndGetExternalIPInternal));
        }
コード例 #2
0
        public override async Task <IPAddress> GetExternalIPAsync()
        {
            var message  = new GetExternalIPAddressMessage(this);
            var response = await SendMessageAsync(message).ConfigureAwait(false);

            if (!(response is GetExternalIPAddressResponseMessage msg))
            {
                throw new MappingException(ErrorCode.Unknown, "Invalid response received when getting the external IP address");
            }
            return(msg.ExternalIPAddress);
        }