private static EmbeddedChannel CreateServerChannel(WebSocketServerProtocolHandler webSocketHandler, IChannelHandler handler)
 {
     return(new EmbeddedChannel(
                new HttpServerCodec(),
                new HttpObjectAggregator(8192),
                webSocketHandler,
                handler));
 }
Example #2
0
        public void HttpUpgradeRequest()
        {
            EmbeddedChannel        ch            = this.CreateChannel(new MockOutboundHandler(this));
            IChannelHandlerContext handshakerCtx = ch.Pipeline.Context <WebSocketServerProtocolHandshakeHandler>();

            WriteUpgradeRequest(ch);

            IFullHttpResponse response = this.responses.Dequeue();

            Assert.Equal(SwitchingProtocols, response.Status);
            response.Release();
            Assert.NotNull(WebSocketServerProtocolHandler.GetHandshaker(handshakerCtx.Channel));
        }
Example #3
0
        public void WebSocketServerProtocolHandshakeHandlerReplacedBeforeHandshake()
        {
            EmbeddedChannel        ch            = CreateChannel(new MockOutboundHandler(this));
            IChannelHandlerContext handshakerCtx = ch.Pipeline.Context <WebSocketServerProtocolHandshakeHandler>();

            ch.Pipeline.AddLast(new ReplacedBeforeHandshakeHandler());
            WriteUpgradeRequest(ch);

            IFullHttpResponse response = _responses.Dequeue();

            Assert.Equal(SwitchingProtocols, response.Status);
            response.Release();
            Assert.NotNull(WebSocketServerProtocolHandler.GetHandshaker(handshakerCtx.Channel));
            Assert.False(ch.Finish());
        }