internal static PortMapAsyncResult Create(MessageBase message, WebRequest request, AsyncCallback storedCallback, object asyncState)
        {
            if (message is GetGenericPortMappingEntry)
            {
                return(new GetAllMappingsAsyncResult(request, storedCallback, asyncState));
            }

            if (message is GetSpecificPortMappingEntryMessage)
            {
                GetSpecificPortMappingEntryMessage mapMessage = (GetSpecificPortMappingEntryMessage)message;
                GetAllMappingsAsyncResult          result     = new GetAllMappingsAsyncResult(request, storedCallback, asyncState);

                result.SpecificMapping = new Mapping(mapMessage.protocol, 0, mapMessage.externalPort, 0);
                return(result);
            }

            return(new PortMapAsyncResult(request, storedCallback, asyncState));
        }
Пример #2
0
        public override IAsyncResult BeginGetSpecificMapping(Protocol protocol, int port, AsyncCallback callback, object asyncState)
        {
            GetSpecificPortMappingEntryMessage message = new GetSpecificPortMappingEntryMessage(protocol, port, this);

            return(this.BeginMessageInternal(message, callback, asyncState, new AsyncCallback(this.EndGetSpecificMappingInternal)));
        }