public LocalChannel(LocalServerChannel parent, LocalChannel peer) : base(parent) { _peer = peer; _localAddress = parent.LocalAddress; _remoteAddress = peer.LocalAddress; Configuration = new DefaultChannelConfiguration(this); _shutdownHook = new ShutdownHook(this); _readTask = new ReadTask(this); }
public LocalServerChannel() { _inboundBuffer = PlatformDependent.NewMpscQueue <object>(); _shutdownHook = () => Unsafe.Close(Unsafe.VoidPromise()); var config = new DefaultChannelConfiguration(this); config.Allocator = new PreferHeapByteBufAllocator(config.Allocator); Configuration = config; }
internal LocalChannel(LocalServerChannel parent, LocalChannel peer) : base(parent) { _inboundBuffer = PlatformDependent.NewMpscQueue <object>(); v_peer = peer; if (parent is object) { v_localAddress = parent.LocalAddress; } if (peer is object) { v_remoteAddress = peer.LocalAddress; } var config = new DefaultChannelConfiguration(this); config.Allocator = new PreferHeapByteBufAllocator(config.Allocator); Configuration = config; shutdownHook = () => Unsafe.Close(Unsafe.VoidPromise()); }
public LocalChannel() : base(null) { Configuration = new DefaultChannelConfiguration(this); _shutdownHook = new ShutdownHook(this); _readTask = new ReadTask(this); }
private volatile int _state; // 0 - open, 1 - active, 2 - closed public LocalServerChannel() { Configuration = new DefaultChannelConfiguration(this); _shutdownHook = new ServerShutdownHook(this); }
public Http2ConnectionHandlerTest() { _connection = new Mock <IHttp2Connection>(); _remoteFlow = new Mock <IHttp2RemoteFlowController>(); _localFlow = new Mock <IHttp2LocalFlowController>(); _remote = new Mock <IHttp2ConnectionEndpoint <IHttp2RemoteFlowController> >(); _remoteFlowController = new Mock <IHttp2RemoteFlowController>(); _local = new Mock <IHttp2ConnectionEndpoint <IHttp2LocalFlowController> >(); _localFlowController = new Mock <IHttp2LocalFlowController>(); _ctx = new Mock <IChannelHandlerContext>(); _executor = new Mock <IEventExecutor>(); _channel = new Mock <IChannel>(); _pipeline = new Mock <IChannelPipeline>(); _stream = new Mock <IHttp2Stream>(); _decoder = new Mock <IHttp2ConnectionDecoder>(); _encoder = new Mock <IHttp2ConnectionEncoder>(); _frameWriter = new Mock <IHttp2FrameWriter>(); _channel.Setup(x => x.Metadata).Returns(new ChannelMetadata(false)); var config = new DefaultChannelConfiguration(_channel.Object); _channel.Setup(x => x.Configuration).Returns(config); _promise = new TaskCompletionSource(); _voidPromise = new TaskCompletionSource(); var fakeException = new Http2RuntimeException("Fake exception"); _future = TaskUtil.FromException(fakeException); _encoder.Setup(x => x.Connection).Returns(_connection.Object); _decoder.Setup(x => x.Connection).Returns(_connection.Object); _encoder.Setup(x => x.FrameWriter).Returns(_frameWriter.Object); _encoder.Setup(x => x.FlowController).Returns(_remoteFlow.Object); _decoder.Setup(x => x.FlowController).Returns(_localFlow.Object); _frameWriter .Setup(x => x.WriteGoAwayAsync( It.IsAny <IChannelHandlerContext>(), It.IsAny <int>(), It.IsAny <Http2Error>(), It.IsAny <IByteBuffer>(), It.IsAny <IPromise>())) .Returns <IChannelHandlerContext, int, Http2Error, IByteBuffer, IPromise>((ctx, id, err, buf, p) => { _goAwayDebugCap = buf.ToString(Encoding.UTF8); buf.Release(); return(_future); }); _channel.Setup(x => x.IsActive).Returns(true); _channel.Setup(x => x.Pipeline).Returns(_pipeline.Object); _connection.Setup(x => x.Remote).Returns(_remote.Object); _remote.Setup(x => x.FlowController).Returns(_remoteFlowController.Object); _connection.Setup(x => x.Local).Returns(_local.Object); _local.Setup(x => x.FlowController).Returns(_localFlowController.Object); _connection .Setup(x => x.ForEachActiveStream(It.IsAny <IHttp2StreamVisitor>())) .Returns <IHttp2StreamVisitor>(visitor => { if (!visitor.Visit(_stream.Object)) { return(_stream.Object); } return(null); }); _connection .Setup(x => x.ForEachActiveStream(It.IsAny <Func <IHttp2Stream, bool> >())) .Returns <Func <IHttp2Stream, bool> >(visitor => { if (!visitor(_stream.Object)) { return(_stream.Object); } return(null); }); _connection.Setup(x => x.Stream(It.Is <int>(v => v == NON_EXISTANT_STREAM_ID))).Returns(default(IHttp2Stream)); _connection.Setup(x => x.NumActiveStreams).Returns(1); _connection.Setup(x => x.Stream(It.Is <int>(v => v == STREAM_ID))).Returns(_stream.Object); _connection .Setup(x => x.GoAwaySent( It.IsAny <int>(), It.IsAny <Http2Error>(), It.IsAny <IByteBuffer>())) .Returns(true); _stream.Setup(x => x.Open(It.IsAny <bool>())).Returns(_stream.Object); _encoder .Setup(x => x.WriteSettingsAsync( It.Is <IChannelHandlerContext>(v => v == _ctx.Object), It.IsAny <Http2Settings>(), It.Is <IPromise>(v => v == _promise))) .Returns(_future); _ctx.Setup(x => x.Allocator).Returns(UnpooledByteBufferAllocator.Default); _ctx.Setup(x => x.Channel).Returns(_channel.Object); _ctx.Setup(x => x.NewPromise()).Returns(_promise); _ctx.Setup(x => x.VoidPromise()).Returns(_voidPromise); _ctx.Setup(x => x.WriteAsync(It.IsAny <object>())).Returns(_future); _ctx.Setup(x => x.Executor).Returns(_executor.Object); _ctx .Setup(x => x.FireChannelRead(It.IsAny <object>())) .Returns <object>(msg => { ReferenceCountUtil.Release(msg); return(_ctx.Object); }); }