예제 #1
0
        public Task <HttpListenerWebSocketContext> AcceptWebSocketAsync(string subProtocol,
                                                                        int receiveBufferSize,
                                                                        TimeSpan keepAliveInterval)
        {
            WebSocketHelpers.ValidateOptions(subProtocol, receiveBufferSize, WebSocketBuffer.MinSendBufferSize, keepAliveInterval);

            ArraySegment <byte> internalBuffer = WebSocketBuffer.CreateInternalBufferArraySegment(receiveBufferSize, WebSocketBuffer.MinSendBufferSize, true);

            return(this.AcceptWebSocketAsync(subProtocol,
                                             receiveBufferSize,
                                             keepAliveInterval,
                                             internalBuffer));
        }
예제 #2
0
        public static Task <WebSocket> AcceptWebSocketAsync(
            this RequestContext context,
            string subProtocol,
            int receiveBufferSize,
            TimeSpan keepAliveInterval,
            ArraySegment <byte> internalBuffer)
        {
            if (!context.IsUpgradableRequest)
            {
                throw new InvalidOperationException("This request is cannot be upgraded.");
            }
            WebSocketHelpers.ValidateOptions(subProtocol, receiveBufferSize, WebSocketBuffer.MinSendBufferSize, keepAliveInterval);
            WebSocketHelpers.ValidateArraySegment <byte>(internalBuffer, "internalBuffer");
            WebSocketBuffer.Validate(internalBuffer.Count, receiveBufferSize, WebSocketBuffer.MinSendBufferSize, true);

            return(AcceptWebSocketAsyncCore(context, subProtocol, receiveBufferSize, keepAliveInterval, internalBuffer));
        }