/// <summary>
        /// Accept web socket with options specified
        /// Call ReadHttpHeaderFromStreamAsync first to get WebSocketHttpContext
        /// </summary>
        /// <param name="context">The http context used to initiate this web socket request</param>
        /// <param name="options">The web socket options</param>
        /// <param name="token">The optional cancellation token</param>
        /// <returns>A connected web socket</returns>
        public async Task <WebSocket> AcceptWebSocketAsync(WebSocketHttpContext context, WebSocketServerOptions options, CancellationToken token = default(CancellationToken))
        {
            Guid guid = Guid.NewGuid();

            Events.Log.AcceptWebSocketStarted(guid);
            await PerformHandshakeAsync(guid, context.HttpHeader, context.Stream, token);

            Events.Log.ServerHandshakeSuccess(guid);
            string secWebSocketExtensions = null;

            return(new WebSocketImplementation(guid, _recycledStreamFactory, context.Stream, options.KeepAliveInterval, secWebSocketExtensions, options.IncludeExceptionInCloseResponse, isClient: false));
        }
 /// <summary>
 /// Accept web socket with default options
 /// Call ReadHttpHeaderFromStreamAsync first to get WebSocketHttpContext
 /// </summary>
 /// <param name="context">The http context used to initiate this web socket request</param>
 /// <param name="token">The optional cancellation token</param>
 /// <returns>A connected web socket</returns>
 public async Task <WebSocket> AcceptWebSocketAsync(WebSocketHttpContext context, CancellationToken token = default(CancellationToken))
 {
     return(await AcceptWebSocketAsync(context, new WebSocketServerOptions(), token));
 }