Example #1
0
        public async Task ProcessRequestAsync()
        {
            string requestString = await ReadRequest();

            if (requestString != null)
            {
                Console.WriteLine("--Request-----");
                Console.WriteLine(requestString);

                var httpRequest = new HttpRequest(requestString);

                var httpResponse = new HttpHandler(this.serverRouteConfig).Handle(httpRequest);

                var responseBytes = Encoding.UTF8.GetBytes(httpResponse.ToString());

                var byteSegment = new ArraySegment <byte>(responseBytes);

                await this.client.SendAsync(byteSegment, SocketFlags.None);

                Console.WriteLine();
                Console.WriteLine("Sessions: " + SessionStore.GetSesions());

                Console.WriteLine("--Response-----");
                Console.WriteLine(httpResponse);
                Console.WriteLine();
            }

            this.client.Shutdown(SocketShutdown.Both);
        }