HttpServer.HttpContextFactory.CreateContext C# (CSharp) Method

CreateContext() protected method

Create a new context.
protected CreateContext ( bool isSecured, IPEndPoint endPoint, Stream stream, Socket sock ) : HttpClientContext
isSecured bool true if socket is running HTTPS.
endPoint System.Net.IPEndPoint Client that connected
stream Stream Network/SSL stream.
sock Socket
return HttpClientContext
        protected HttpClientContext CreateContext(bool isSecured, IPEndPoint endPoint, Stream stream, Socket sock)
        {
        	HttpClientContext context;
            lock (_contextQueue)
            {
                if (_contextQueue.Count > 0)
                {
                    context = _contextQueue.Dequeue();
                    if (!context.Available)
                    {
                        context = CreateNewContext(isSecured, endPoint, stream, sock);
                        context.Disconnected += OnFreeContext;
                        context.RequestReceived += OnRequestReceived;
                        context.EndWhenDone = true;
                    }
                }
                else
                {
                    context = CreateNewContext(isSecured, endPoint, stream, sock);
                    context.Disconnected += OnFreeContext;
                    context.RequestReceived += OnRequestReceived;
                }
            }

        	context.Stream = stream;
			context.IsSecured = isSecured;
			context.RemotePort = endPoint.Port.ToString();
			context.RemoteAddress = endPoint.Address.ToString();
			context.Start();
            return context;
        }

Same methods

HttpContextFactory::CreateContext ( Socket socket ) : IHttpClientContext