Пример #1
0
        public async Task <IProtocolObject> TryConsumeStreamObjectOfType(Type type)
        {
            //Read the next incoming request message
            await RequestReader.ParseNextRequest().ConfigureAwait(false);

            //Is it of the correct type
            if (RequestReader.GetObjectType() != type)
            {
                return(null);
            }

            //Create and return an object from the request message
            return(ProtocolObjectFactory.CreateObject(RequestReader.GetObjectType(), RequestReader.CurrentObjectData));
        }
Пример #2
0
        public async Task ProcessStreamObjects()
        {
            BreakProcessLoop = false;

            while (!BreakProcessLoop && await RequestReader.ParseNextRequest().ConfigureAwait(false))
            {
                var protocolObject = ProtocolObjectFactory.CreateObject(RequestReader.GetObjectType(), RequestReader.CurrentObjectData);
                protocolObject.ProtocolEvent += BreakLoopEvent;

                await protocolObject.Process(this).ConfigureAwait(false);
                await SendResponse(protocolObject).ConfigureAwait(false);

                Trace.Flush();
            }

            BreakProcessLoop = false;   //Ensure that any process loops that this one is running within still continue.
        }