/// <summary>
        /// Each time an application receives new request, this method checks wether or not its web socket
        /// request. If it is, then the request is being handled accordingly.
        /// </summary>
        public async Task InvokeAsync(HttpContext httpContext, [FromServices] GameServerService gameServer)
        {
            if (httpContext.Request.Path == "/ws")
            {
                if (httpContext.WebSockets.IsWebSocketRequest)
                {
                    WebSocket webSocket = await httpContext.WebSockets.AcceptWebSocketAsync();

                    // Pass new web socket to be handled.
                    await gameServer.HandleWebSocketAsync(webSocket);
                }
                else
                {
                    httpContext.Response.StatusCode = 400;
                }
            }
            else
            {
                await _next(httpContext);
            }
        }