/// <inheritdoc /> public override void HandlerRemoved(IChannelHandlerContext context) { if (_decodeState == STATE_CALLING_CHILD_DECODE) { _decodeState = STATE_HANDLER_REMOVED_PENDING; return; } IByteBuffer buf = _cumulation; if (buf is object) { // Directly set this to null so we are sure we not access it in any other method here anymore. _cumulation = null; _numReads = 0; int readable = buf.ReadableBytes; if (readable > 0) { _ = context.FireChannelRead(buf); _ = context.FireChannelReadComplete(); } else { _ = buf.Release(); } } HandlerRemovedInternal(context); }
public override void ChannelRead(IChannelHandlerContext context, object message) { try { IByteBuffer response = ExtractResponse(message); if (response != null) { int sequenceId = ExtractSequenceId(response); OnResponseReceived(sequenceId, response); } else // for one-way { //FireResponseReceivedCallback(request.Listener, response); } } catch (Exception t) { OnError(t); } finally { Interlocked.Decrement(ref _invoked); context.FireChannelReadComplete(); } }
/** * Dequeues one or many (or none) messages depending on the channel's auto * reading state and returns the number of messages that were consumed from * the internal queue. * * The {@code minConsume} argument is used to force {@code dequeue()} into * consuming that number of messages regardless of the channel's auto * reading configuration. * * @see #read(ChannelHandlerContext) * @see #channelRead(ChannelHandlerContext, Object) */ int Dequeue(IChannelHandlerContext ctx, int minConsume) { if (this.queue != null) { int consumed = 0; while ((consumed < minConsume || this.config.AutoRead) && this.queue.TryDequeue(out object msg)) { ++consumed; ctx.FireChannelRead(msg); } // We're firing a completion event every time one (or more) // messages were consumed and the queue ended up being drained // to an empty state. if (this.queue.IsEmpty && consumed > 0) { ctx.FireChannelReadComplete(); } return(consumed); } return(0); }
/** * Dequeues one or many (or none) messages depending on the channel's auto * reading state and returns the number of messages that were consumed from * the internal queue. * * The {@code minConsume} argument is used to force {@code dequeue()} into * consuming that number of messages regardless of the channel's auto * reading configuration. * * @see #read(ChannelHandlerContext) * @see #channelRead(ChannelHandlerContext, Object) */ private int Dequeue(IChannelHandlerContext ctx, int minConsume) { int consumed = 0; // fireChannelRead(...) may call ctx.read() and so this method may reentrance. Because of this we need to // check if queue was set to null in the meantime and if so break the loop. while (_queue is object && (consumed < minConsume || _config.IsAutoRead)) { if (!_queue.TryDequeue(out object msg) || msg is null) { break; } ++consumed; _ = ctx.FireChannelRead(msg); } // We're firing a completion event every time one (or more) // messages were consumed and the queue ended up being drained // to an empty state. if (_queue is object && _queue.IsEmpty) { _queue.Recycle(); _queue = null; if (consumed > 0) { _ = ctx.FireChannelReadComplete(); } } return(consumed); }
public override void ChannelReadComplete(IChannelHandlerContext ctx) { if (Logger.IsEnabled(InternalLevel)) { Logger.Log(InternalLevel, Format(ctx, "RECEIVED_COMPLETE")); } ctx.FireChannelReadComplete(); }
/// <inheritdoc /> public override void ChannelReadComplete(IChannelHandlerContext ctx) { if (Logger.IsEnabled(MsLogLevel.Trace)) { Logger.LogTrace("Channel {0} receive complete", ctx.Channel); } ctx.FireChannelReadComplete(); }
public override void ChannelReadComplete(IChannelHandlerContext context) { if ((_readerIdleTime.Ticks > 0 || _allIdleTime.Ticks > 0) && _reading) { _lastReadTime = Ticks(); _reading = false; } _ = context.FireChannelReadComplete(); }
public override void ChannelReadComplete(IChannelHandlerContext ctx) { // Discard bytes of the cumulation buffer if needed. DiscardSomeReadBytes(); ReadIfNeeded(ctx); _firedChannelRead = false; _ = ctx.FireChannelReadComplete(); }
public override void ChannelReadComplete(IChannelHandlerContext context) { if (this.readerIdleTime.Ticks > 0 || this.allIdleTime.Ticks > 0) { this.lastReadTime = TimeUtil.GetSystemTime(); this.reading = false; } context.FireChannelReadComplete(); }
public override void ChannelReadComplete(IChannelHandlerContext context) { if ((this.readerIdleTime.Ticks > 0 || this.allIdleTime.Ticks > 0) && reading) { this.lastReadTime = this.Ticks(); this.reading = false; } context.FireChannelReadComplete(); }
private void ChannelInputClosed(IChannelHandlerContext context, bool callChannelInactive) { var output = RecyclableArrayList.Take(); try { if (_cumulation != null) { CallDecode(context, _cumulation, output); DecodeLast(context, _cumulation, output); } else { DecodeLast(context, Unpooled.Empty, output); } } catch (DecoderException) { throw; } catch (Exception ex) { throw new DecoderException(ex); } finally { try { if (_cumulation != null) { _cumulation.Release(); _cumulation = null; } var size = output.Count; FireChannelRead(context, output, size); if (size > 0) { // Something was read, call FireChannelReadComplete() context.FireChannelReadComplete(); } if (callChannelInactive) { context.FireChannelInactive(); } } finally { // recycle in all cases output.Return(); } } }
/// <inheritdoc /> public override void ChannelReadComplete(IChannelHandlerContext context) { _numReads = 0; DiscardSomeReadBytes(); if (!_firedChannelRead && !context.Channel.Configuration.IsAutoRead) { _ = context.Read(); } _firedChannelRead = false; _ = context.FireChannelReadComplete(); }
public override void ChannelInactive(IChannelHandlerContext ctx) { ThreadLocalObjectList output = ThreadLocalObjectList.NewInstance(); try { if (this.cumulation != null) { this.CallDecode(ctx, this.cumulation, output); this.DecodeLast(ctx, this.cumulation, output); } else { this.DecodeLast(ctx, Unpooled.Empty, output); } } catch (DecoderException e) { throw e; } catch (Exception e) { throw new DecoderException(e); } finally { try { if (this.cumulation != null) { this.cumulation.Release(); this.cumulation = null; } int size = output.Count; for (int i = 0; i < size; i++) { ctx.FireChannelRead(output[i]); } if (size > 0) { // Something was read, call fireChannelReadComplete() ctx.FireChannelReadComplete(); } ctx.FireChannelInactive(); } finally { // recycle in all cases output.Return(); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void channelInactive(io.netty.channel.IChannelHandlerContext ctx) throws Exception public override void ChannelInactive(IChannelHandlerContext ctx) { var @out = new List <object>(); try { if (cumulation != null) { callDecode(ctx, cumulation, @out); decodeLast(ctx, cumulation, @out); } else { decodeLast(ctx, Unpooled.Empty, @out); } } catch (DecoderException) { throw; } catch (Exception e) { throw new DecoderException(e); } finally { try { if (cumulation != null) { cumulation.Release(); cumulation = null; } int size = @out.Count; for (int i = 0; i < size; i++) { ctx.FireChannelRead(@out[i]); } if (size > 0) { // Something was read, call fireChannelReadComplete() ctx.FireChannelReadComplete(); } ctx.FireChannelInactive(); } finally { // recycle in all cases //@out.recycle(); } } }
public override void ChannelReadComplete(IChannelHandlerContext context) { if (_suppressChannelReadComplete) { _suppressChannelReadComplete = false; ReadIfNeeded(_ctx); } else { _ctx.FireChannelReadComplete(); } }
public override void ChannelReadComplete(IChannelHandlerContext context) { this.DiscardSomeReadBytes(); if (this.decodeWasNull) { this.decodeWasNull = false; if (!context.Channel.Configuration.AutoRead) { context.Read(); } } context.FireChannelReadComplete(); }
public override void ChannelReadComplete(IChannelHandlerContext ctx) { if (IsQueueEmpty) { _ = ctx.FireChannelReadComplete(); } else { // Don't relay completion events from upstream as they // make no sense in this context. See dequeue() where // a new set of completion events is being produced. } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void channelReadComplete(io.netty.channel.IChannelHandlerContext ctx) throws Exception public override void ChannelReadComplete(IChannelHandlerContext ctx) { numReads = 0; discardSomeReadBytes(); if (decodeWasNull) { decodeWasNull = false; if (!ctx.Channel.Configuration.AutoRead) { ctx.Read(); } } ctx.FireChannelReadComplete(); }
/// <summary>Process all backlog into pipeline from List.</summary> private void FireBufferedMessages() { if (0u >= (uint)_bufferedMessages.Count) { return; } for (int i = 0; i < _bufferedMessages.Count; i++) { _ctx.FireChannelRead(_bufferedMessages[i]); } _ctx.FireChannelReadComplete(); _bufferedMessages.Clear(); }
public override void ChannelReadComplete(IChannelHandlerContext context) { var needRead = _needRead; _needRead = true; try { _ = context.FireChannelReadComplete(); } finally { if (needRead && !context.Channel.Configuration.IsAutoRead) { _ = context.Read(); } } }
private void ChannelInputClosed(IChannelHandlerContext ctx, bool callChannelInactive) { ThreadLocalObjectList output = ThreadLocalObjectList.NewInstance(); try { ChannelInputClosed(ctx, output); } catch (DecoderException) { throw; } catch (Exception e) { CThrowHelper.ThrowDecoderException(e); } finally { try { if (_cumulation is object) { _ = _cumulation.Release(); _cumulation = null; } int size = output.Count; if ((uint)size > 0u) { FireChannelRead(ctx, output, size); // Something was read, call fireChannelReadComplete() _ = ctx.FireChannelReadComplete(); } if (callChannelInactive) { _ = ctx.FireChannelInactive(); } } finally { // Recycle in all cases output.Return(); } } }
public override void HandlerRemoved(IChannelHandlerContext context) { IByteBuffer buf = this.InternalBuffer; int readable = buf.ReadableBytes; if (readable > 0) { IByteBuffer bytes = buf.ReadBytes(readable); buf.Release(); context.FireChannelRead(bytes); } else { buf.Release(); } this.cumulation = null; context.FireChannelReadComplete(); this.HandlerRemovedInternal(context); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public final void handlerRemoved(io.netty.channel.IChannelHandlerContext ctx) throws Exception public override void HandlerRemoved(IChannelHandlerContext ctx) { IByteBuffer buf = internalBuffer(); int readable = buf.ReadableBytes; if (readable > 0) { IByteBuffer bytes = buf.ReadBytes(readable); buf.Release(); ctx.FireChannelRead(bytes); } else { buf.Release(); } cumulation = null; numReads = 0; ctx.FireChannelReadComplete(); handlerRemoved0(ctx); }
public override void HandlerRemoved(IChannelHandlerContext context) { var buf = InternalBuffer; var readable = buf.ReadableBytes; if (readable > 0) { var bytes = buf.ReadBytes(readable); buf.Release(); context.FireChannelRead(bytes); } else { buf.Release(); } _cumulation = null; _numReads = 0; context.FireChannelReadComplete(); HandlerRemovedInternal(context); }
public override void HandlerRemoved(IChannelHandlerContext context) { IByteBuffer buf = this.InternalBuffer; // Directly set this to null so we are sure we not access it in any other method here anymore. this.cumulation = null; int readable = buf.ReadableBytes; if (readable > 0) { IByteBuffer bytes = buf.ReadBytes(readable); buf.Release(); context.FireChannelRead(bytes); } else { buf.Release(); } context.FireChannelReadComplete(); this.HandlerRemovedInternal(context); }
public override void ChannelReadComplete(IChannelHandlerContext context) { this.DiscardSomeReadBytes(); if (this.decodeWasNull) { this.decodeWasNull = false; if (!context.Channel.Configuration.AutoRead) { context.Read(); } } context.FireChannelReadComplete(); }
public override void HandlerRemoved(IChannelHandlerContext context) { IByteBuffer buf = this.InternalBuffer; int readable = buf.ReadableBytes; if (readable > 0) { IByteBuffer bytes = buf.ReadBytes(readable); buf.Release(); context.FireChannelRead(bytes); } else { buf.Release(); } this.cumulation = null; context.FireChannelReadComplete(); this.HandlerRemovedInternal(context); }
public IChannelHandlerContext FireChannelReadComplete() { _ = _ctx.FireChannelReadComplete(); return(this); }
/// <summary> /// The ChannelReadComplete executes after the entire ChannelPipeline has been executed. /// </summary> public override void ChannelReadComplete(IChannelHandlerContext ctx) { ctx.WriteAndFlushAsync($"Your message contained {MessageLenght} chars." + System.Environment.NewLine); ctx.FireChannelReadComplete(); }
public void ChannelReadComplete(IChannelHandlerContext ctx) { ctx.FireChannelReadComplete(); this.ReadIfIsAutoRead(); }
private void ChannelInputClosed(IChannelHandlerContext context, bool callChannelInactive) { var output = RecyclableArrayList.Take(); try { if (_cumulation != null) { CallDecode(context, _cumulation, output); DecodeLast(context, _cumulation, output); } else { DecodeLast(context, Unpooled.Empty, output); } } catch (DecoderException) { throw; } catch (Exception ex) { throw new DecoderException(ex); } finally { try { if (_cumulation != null) { _cumulation.Release(); _cumulation = null; } var size = output.Count; FireChannelRead(context, output, size); if (size > 0) { // Something was read, call FireChannelReadComplete() context.FireChannelReadComplete(); } if (callChannelInactive) { context.FireChannelInactive(); } } finally { // recycle in all cases output.Return(); } } }
public void ChannelReadComplete(IChannelHandlerContext ctx) { ctx.FireChannelReadComplete(); }
public override void ChannelInactive(IChannelHandlerContext ctx) { ThreadLocalObjectList output = ThreadLocalObjectList.Take(); try { if (this.cumulation != null) { this.CallDecode(ctx, this.cumulation, output); this.DecodeLast(ctx, this.cumulation, output); } else { this.DecodeLast(ctx, Unpooled.Empty, output); } } catch (DecoderException e) { throw e; } catch (Exception e) { throw new DecoderException(e); } finally { try { if (this.cumulation != null) { this.cumulation.Release(); this.cumulation = null; } int size = output.Count; for (int i = 0; i < size; i++) { ctx.FireChannelRead(output[i]); } if (size > 0) { // Something was read, call fireChannelReadComplete() ctx.FireChannelReadComplete(); } ctx.FireChannelInactive(); } finally { // recycle in all cases output.Return(); } } }
public virtual void ChannelReadComplete(IChannelHandlerContext context) => context.FireChannelReadComplete();
public override void ChannelReadComplete(IChannelHandlerContext context) { if (this.readerIdleTime.Ticks > 0 || this.allIdleTime.Ticks > 0) { this.lastReadTime = TimeUtil.GetSystemTime(); this.reading = false; } context.FireChannelReadComplete(); }
public override void HandlerRemoved(IChannelHandlerContext context) { var buf = InternalBuffer; var readable = buf.ReadableBytes; if (readable > 0) { var bytes = buf.ReadBytes(readable); buf.Release(); context.FireChannelRead(bytes); } else { buf.Release(); } _cumulation = null; _numReads = 0; context.FireChannelReadComplete(); HandlerRemovedInternal(context); }
public override void ChannelReadComplete(IChannelHandlerContext context) { this.lastReadTime = TimeUtil.GetSystemTime(); this.reading = false; context.FireChannelReadComplete(); }