From 1633c27beffe56977c6be80e257faad2178c099c Mon Sep 17 00:00:00 2001 From: cuteant Date: Tue, 25 May 2021 22:53:58 +0800 Subject: [PATCH] Compatibility with DotNetty --- .../AbstractHttp2StreamChannel.cs | 9 +++++++++ src/DotNetty.Transport/Channels/AbstractChannel.cs | 9 +++++++++ .../Channels/AbstractChannelHandlerContext.cs | 2 +- .../CombinedChannelDuplexHandler.Context.cs | 3 +++ .../Channels/DefaultChannelConfiguration.cs | 14 ++++++++++++++ src/DotNetty.Transport/Channels/IChannel.cs | 9 +++++++++ .../Channels/IChannelConfiguration.cs | 10 ++++++++++ .../Channels/IChannelHandlerContext.cs | 8 ++++++++ .../Http2FrameInboundWriter.cs | 1 + 9 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/DotNetty.Codecs.Http2/AbstractHttp2StreamChannel.cs b/src/DotNetty.Codecs.Http2/AbstractHttp2StreamChannel.cs index a03cd70f8..3ea71ac64 100644 --- a/src/DotNetty.Codecs.Http2/AbstractHttp2StreamChannel.cs +++ b/src/DotNetty.Codecs.Http2/AbstractHttp2StreamChannel.cs @@ -128,12 +128,18 @@ internal void StreamClosed() public IChannelConfiguration Configuration => _config; + [Obsolete("Please use IsOpen instead.")] + public bool Open => IsOpen; + public bool IsOpen { [MethodImpl(InlineMethod.AggressiveOptimization)] get => !_closePromise.IsCompleted; } + [Obsolete("Please use IsActive instead.")] + public bool Active => IsActive; + public bool IsActive => IsOpen; public bool IsWritable => 0u >= (uint)Volatile.Read(ref v_unwritable); @@ -144,6 +150,9 @@ public bool IsOpen public IChannel Parent => ParentContext.Channel; + [Obsolete("Please use IsRegistered instead.")] + public bool Registered => IsRegistered; + public bool IsRegistered => InternalRegistered; public EndPoint LocalAddress => Parent.LocalAddress; diff --git a/src/DotNetty.Transport/Channels/AbstractChannel.cs b/src/DotNetty.Transport/Channels/AbstractChannel.cs index 60f579533..fcd388a21 100644 --- a/src/DotNetty.Transport/Channels/AbstractChannel.cs +++ b/src/DotNetty.Transport/Channels/AbstractChannel.cs @@ -150,8 +150,14 @@ public IEventLoop EventLoop } } + [Obsolete("Please use IsOpen instead.")] + public bool Open => IsOpen; + public abstract bool IsOpen { get; } + [Obsolete("Please use IsActive instead.")] + public bool Active => IsActive; + public abstract bool IsActive { get; } public abstract ChannelMetadata Metadata { get; } @@ -215,6 +221,9 @@ protected EndPoint CacheRemoteAddress() } } + [Obsolete("Please use IsRegistered instead.")] + public bool Registered => IsRegistered; + public bool IsRegistered => SharedConstants.False < (uint)Volatile.Read(ref v_registered); /// diff --git a/src/DotNetty.Transport/Channels/AbstractChannelHandlerContext.cs b/src/DotNetty.Transport/Channels/AbstractChannelHandlerContext.cs index 1ff468f58..ecbcabd17 100644 --- a/src/DotNetty.Transport/Channels/AbstractChannelHandlerContext.cs +++ b/src/DotNetty.Transport/Channels/AbstractChannelHandlerContext.cs @@ -116,7 +116,7 @@ private bool InvokeHandler } } - [Obsolete("=>IsRemoved")] + [Obsolete("Please use IsRemoved instead.")] public bool Removed => IsRemoved; public bool IsRemoved => 0u >= (uint)(Volatile.Read(ref v_handlerState) - HandlerState.RemoveComplete); diff --git a/src/DotNetty.Transport/Channels/CombinedChannelDuplexHandler.Context.cs b/src/DotNetty.Transport/Channels/CombinedChannelDuplexHandler.Context.cs index 8de0879f0..e27987e53 100644 --- a/src/DotNetty.Transport/Channels/CombinedChannelDuplexHandler.Context.cs +++ b/src/DotNetty.Transport/Channels/CombinedChannelDuplexHandler.Context.cs @@ -61,6 +61,9 @@ public DelegatingChannelHandlerContext(IChannelHandlerContext ctx, IChannelHandl public IChannelHandler Handler => _ctx.Handler; + [Obsolete("Please use IsRemoved instead.")] + public bool Removed => IsRemoved; + public bool IsRemoved => _removed || _ctx.IsRemoved; public IChannelHandlerContext FireChannelRegistered() diff --git a/src/DotNetty.Transport/Channels/DefaultChannelConfiguration.cs b/src/DotNetty.Transport/Channels/DefaultChannelConfiguration.cs index e207c49f2..9172c5ad4 100644 --- a/src/DotNetty.Transport/Channels/DefaultChannelConfiguration.cs +++ b/src/DotNetty.Transport/Channels/DefaultChannelConfiguration.cs @@ -241,6 +241,13 @@ public virtual IMessageSizeEstimator MessageSizeEstimator } } + [Obsolete("Please use IsAutoRead instead.")] + public bool AutoRead + { + get => IsAutoRead; + set => IsAutoRead = value; + } + public bool IsAutoRead { get { return SharedConstants.False < (uint)Volatile.Read(ref _autoRead); } @@ -264,6 +271,13 @@ protected virtual void AutoReadCleared() { } + [Obsolete("Please use IsAutoClose instead.")] + public bool AutoClose + { + get => IsAutoClose; + set => IsAutoClose = value; + } + public bool IsAutoClose { get { return SharedConstants.False < (uint)Volatile.Read(ref _autoClose); } diff --git a/src/DotNetty.Transport/Channels/IChannel.cs b/src/DotNetty.Transport/Channels/IChannel.cs index 6933b86f8..9bb5486c6 100644 --- a/src/DotNetty.Transport/Channels/IChannel.cs +++ b/src/DotNetty.Transport/Channels/IChannel.cs @@ -107,6 +107,15 @@ public interface IChannel : IAttributeMap, IComparable, IEquatable IChannel Parent { get; } + [Obsolete("Please use IsOpen instead.")] + bool Open { get; } + + [Obsolete("Please use IsActive instead.")] + bool Active { get; } + + [Obsolete("Please use IsRegistered instead.")] + bool Registered { get; } + /// /// Returns true if the is open and may get active later. /// diff --git a/src/DotNetty.Transport/Channels/IChannelConfiguration.cs b/src/DotNetty.Transport/Channels/IChannelConfiguration.cs index 18a6eea29..a43fa97be 100644 --- a/src/DotNetty.Transport/Channels/IChannelConfiguration.cs +++ b/src/DotNetty.Transport/Channels/IChannelConfiguration.cs @@ -67,10 +67,20 @@ public interface IChannelConfiguration /// Gets or sets the which is used for the channel to allocate receive buffers. IRecvByteBufAllocator RecvByteBufAllocator { get; set; } + /// Gets or sets if will be invoked automatically so that a user application doesn't + /// need to call it at all. The default value is true. + [Obsolete("Please use IsAutoRead instead.")] + bool AutoRead { get; set; } + /// Gets or sets if will be invoked automatically so that a user application doesn't /// need to call it at all. The default value is true. bool IsAutoRead { get; set; } + /// Gets or sets whether the should be closed automatically and immediately on write failure. + /// The default is true. + [Obsolete("Please use IsAutoClose instead.")] + bool AutoClose { get; set; } + /// Gets or sets whether the should be closed automatically and immediately on write failure. /// The default is true. bool IsAutoClose { get; set; } diff --git a/src/DotNetty.Transport/Channels/IChannelHandlerContext.cs b/src/DotNetty.Transport/Channels/IChannelHandlerContext.cs index eefe1da30..8f7de81f9 100644 --- a/src/DotNetty.Transport/Channels/IChannelHandlerContext.cs +++ b/src/DotNetty.Transport/Channels/IChannelHandlerContext.cs @@ -168,6 +168,14 @@ public interface IChannelHandlerContext : IAttributeMap /// IChannelHandler Handler { get; } + /// + /// Return true if the which belongs to this context was removed + /// from the . Note that this method is only meant to be called from with in the + /// . + /// + [Obsolete("Please use IsRemoved instead.")] + bool Removed { get; } + /// /// Return true if the which belongs to this context was removed /// from the . Note that this method is only meant to be called from with in the diff --git a/test/DotNetty.Codecs.Http2.Tests/Http2FrameInboundWriter.cs b/test/DotNetty.Codecs.Http2.Tests/Http2FrameInboundWriter.cs index 7ae4f0e79..1d89834c2 100644 --- a/test/DotNetty.Codecs.Http2.Tests/Http2FrameInboundWriter.cs +++ b/test/DotNetty.Codecs.Http2.Tests/Http2FrameInboundWriter.cs @@ -112,6 +112,7 @@ public WriteInboundChannelHandlerContext(EmbeddedChannel channel) public IChannelHandler Handler => this; + public bool Removed => false; public bool IsRemoved => false; public IChannelPipeline Pipeline => _channel.Pipeline;