├── .gitattributes ├── .gitignore ├── .nuget └── NuGet.Config ├── .vscode ├── launch.json └── tasks.json ├── CONTRIBUTING.MD ├── Directory.Build.targets ├── DotNetty.sln ├── DotNetty.sln.DotSettings ├── DotNetty.snk ├── LICENSE.txt ├── README.md ├── RELEASE_NOTES.md ├── SECURITY.md ├── ThirdPartyNotices.txt ├── after.DotNetty.sln.targets ├── appveyor.yml ├── build.cake ├── build.ps1 ├── build.sh ├── examples ├── Discard.Client │ ├── Discard.Client.csproj │ ├── DiscardClientHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Discard.Server │ ├── Discard.Server.csproj │ ├── DiscardServerHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Echo.Client │ ├── Echo.Client.csproj │ ├── EchoClientHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Echo.Server │ ├── Echo.Server.csproj │ ├── EchoServerHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Examples.Common │ ├── ClientSettings.cs │ ├── ExampleHelper.cs │ ├── Examples.Common.csproj │ └── ServerSettings.cs ├── Factorial.Client │ ├── ClientSettings.cs │ ├── Factorial.Client.csproj │ ├── FactorialClientHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Factorial.Server │ ├── Factorial.Server.csproj │ ├── FactorialServerHandler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── Factorial │ ├── BigIntegerDecoder.cs │ ├── Factorial.csproj │ ├── NumberEncoder.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── HttpServer │ ├── HelloServerHandler.cs │ ├── HttpServer.csproj │ ├── MessageBody.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── appsettings.json ├── QuoteOfTheMoment.Client │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── QuoteOfTheMoment.Client.csproj │ ├── QuoteOfTheMomentClientHandler.cs │ └── appsettings.json ├── QuoteOfTheMoment.Server │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── QuoteOfTheMoment.Server.csproj │ ├── QuoteOfTheMomentServerHandler.cs │ └── appsettings.json ├── SecureChat.Client │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SecureChat.Client.csproj │ ├── SecureChatClientHandler.cs │ └── appsettings.json ├── SecureChat.Server │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SecureChat.Server.csproj │ ├── SecureChatServerHandler.cs │ └── appsettings.json ├── Telnet.Client │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Telnet.Client.csproj │ ├── TelnetClientHandler.cs │ └── appsettings.json ├── Telnet.Server │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Telnet.Server.csproj │ ├── TelnetServerHandler.cs │ └── appsettings.json ├── UWPEcho.Client │ ├── App.xaml │ ├── App.xaml.cs │ ├── Assets │ │ ├── LockScreenLogo.scale-200.png │ │ ├── SplashScreen.scale-200.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── StoreLogo.png │ │ └── Wide310x150Logo.scale-200.png │ ├── EchoClientHandler.cs │ ├── MainPage.xaml │ ├── MainPage.xaml.cs │ ├── Package.appxmanifest │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Default.rd.xml │ ├── StreamSocketChannel.cs │ ├── UWPEcho.Client.csproj │ ├── UWPEcho.Client.sln │ ├── UWPEcho.Client_TemporaryKey.pfx │ ├── UWPPlatform.cs │ ├── project.json │ └── readme.md ├── WebSockets.Client │ ├── Program.cs │ ├── WebSocketClientHandler.cs │ ├── WebSockets.Client.csproj │ └── appsettings.json └── WebSockets.Server │ ├── Program.cs │ ├── WebSocketServerBenchmarkPage.cs │ ├── WebSocketServerHandler.cs │ ├── WebSockets.Server.csproj │ └── appsettings.json ├── shared ├── contoso.com.pfx └── dotnetty.com.pfx ├── src ├── Directory.Build.props ├── DotNetty.Buffers │ ├── AbstractByteBuffer.cs │ ├── AbstractByteBufferAllocator.cs │ ├── AbstractDerivedByteBuffer.cs │ ├── AbstractPooledDerivedByteBuffer.cs │ ├── AbstractReferenceCountedByteBuffer.cs │ ├── AbstractUnpooledSlicedByteBuffer.cs │ ├── AdvancedLeakAwareByteBuffer.cs │ ├── AdvancedLeakAwareCompositeByteBuffer.cs │ ├── ByteBufferUtil.cs │ ├── ByteOrder.cs │ ├── CompositeByteBuffer.cs │ ├── DefaultByteBufferHolder.cs │ ├── DotNetty.Buffers.csproj │ ├── EmptyByteBuffer.cs │ ├── HeapByteBufferUtil.cs │ ├── IByteBuffer.cs │ ├── IByteBufferAllocator.cs │ ├── IByteBufferAllocatorMetric.cs │ ├── IByteBufferAllocatorMetricProvider.cs │ ├── IByteBufferHolder.cs │ ├── IPoolArenaMetric.cs │ ├── IPoolChunkListMetric.cs │ ├── IPoolChunkMetric.cs │ ├── IPoolSubpageMetric.cs │ ├── PoolArena.cs │ ├── PoolChunk.cs │ ├── PoolChunkList.cs │ ├── PoolSubpage.cs │ ├── PoolThreadCache.cs │ ├── PooledByteBuffer.cs │ ├── PooledByteBufferAllocator.cs │ ├── PooledByteBufferAllocatorMetric.cs │ ├── PooledDuplicatedByteBuffer.cs │ ├── PooledHeapByteBuffer.cs │ ├── PooledSlicedByteBuffer.cs │ ├── PooledUnsafeDirectByteBuffer.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── ReadOnlyByteBufferStream.cs │ ├── SimpleLeakAwareByteBuffer.cs │ ├── SimpleLeakAwareCompositeByteBuffer.cs │ ├── ThrowHelper.cs │ ├── Unpooled.cs │ ├── UnpooledByteBufferAllocator.cs │ ├── UnpooledDuplicatedByteBuffer.cs │ ├── UnpooledHeapByteBuffer.cs │ ├── UnpooledSlicedByteBuffer.cs │ ├── UnpooledUnsafeDirectByteBuffer.cs │ ├── UnreleasableByteBuffer.cs │ ├── UnsafeByteBufferUtil.cs │ ├── WrappedByteBuffer.cs │ └── WrappedCompositeByteBuffer.cs ├── DotNetty.Codecs.Http │ ├── CombinedHttpHeaders.cs │ ├── ComposedLastHttpContent.cs │ ├── Cookies │ │ ├── ClientCookieDecoder.cs │ │ ├── ClientCookieEncoder.cs │ │ ├── CookieDecoder.cs │ │ ├── CookieEncoder.cs │ │ ├── CookieHeaderNames.cs │ │ ├── CookieUtil.cs │ │ ├── DefaultCookie.cs │ │ ├── ICookie.cs │ │ ├── ServerCookieDecoder.cs │ │ └── ServerCookieEncoder.cs │ ├── Cors │ │ ├── CorsConfig.cs │ │ ├── CorsConfigBuilder.cs │ │ └── CorsHandler.cs │ ├── DefaultFullHttpRequest.cs │ ├── DefaultFullHttpResponse.cs │ ├── DefaultHttpContent.cs │ ├── DefaultHttpHeaders.cs │ ├── DefaultHttpMessage.cs │ ├── DefaultHttpObject.cs │ ├── DefaultHttpRequest.cs │ ├── DefaultHttpResponse.cs │ ├── DefaultLastHttpContent.cs │ ├── DotNetty.Codecs.Http.csproj │ ├── EmptyHttpHeaders.cs │ ├── EmptyLastHttpContent.cs │ ├── HttpChunkedInput.cs │ ├── HttpClientCodec.cs │ ├── HttpClientUpgradeHandler.cs │ ├── HttpConstants.cs │ ├── HttpContentCompressor.cs │ ├── HttpContentDecoder.cs │ ├── HttpContentDecompressor.cs │ ├── HttpContentEncoder.cs │ ├── HttpExpectationFailedEvent.cs │ ├── HttpHeaderNames.cs │ ├── HttpHeaderValues.cs │ ├── HttpHeaders.cs │ ├── HttpHeadersEncoder.cs │ ├── HttpMessageUtil.cs │ ├── HttpMethod.cs │ ├── HttpObjectAggregator.cs │ ├── HttpObjectDecoder.cs │ ├── HttpObjectEncoder.cs │ ├── HttpRequestDecoder.cs │ ├── HttpRequestEncoder.cs │ ├── HttpResponseDecoder.cs │ ├── HttpResponseEncoder.cs │ ├── HttpResponseStatus.cs │ ├── HttpScheme.cs │ ├── HttpServerCodec.cs │ ├── HttpServerExpectContinueHandler.cs │ ├── HttpServerKeepAliveHandler.cs │ ├── HttpServerUpgradeHandler.cs │ ├── HttpStatusClass.cs │ ├── HttpUtil.cs │ ├── HttpVersion.cs │ ├── IFullHttpMessage.cs │ ├── IFullHttpRequest.cs │ ├── IFullHttpResponse.cs │ ├── IHttpContent.cs │ ├── IHttpMessage.cs │ ├── IHttpObject.cs │ ├── IHttpRequest.cs │ ├── IHttpResponse.cs │ ├── ILastHttpContent.cs │ ├── Multipart │ │ ├── AbstractDiskHttpData.cs │ │ ├── AbstractHttpData.cs │ │ ├── AbstractMemoryHttpData.cs │ │ ├── CaseIgnoringComparator.cs │ │ ├── DefaultHttpDataFactory.cs │ │ ├── DiskAttribute.cs │ │ ├── DiskFileUpload.cs │ │ ├── EndOfDataDecoderException.cs │ │ ├── ErrorDataDecoderException.cs │ │ ├── ErrorDataEncoderException.cs │ │ ├── FileUploadUtil.cs │ │ ├── HttpPostBodyUtil.cs │ │ ├── HttpPostMultipartRequestDecoder.cs │ │ ├── HttpPostRequestDecoder.cs │ │ ├── HttpPostRequestEncoder.cs │ │ ├── HttpPostStandardRequestDecoder.cs │ │ ├── IAttribute.cs │ │ ├── IFileUpload.cs │ │ ├── IHttpData.cs │ │ ├── IHttpDataFactory.cs │ │ ├── IInterfaceHttpData.cs │ │ ├── IInterfaceHttpPostRequestDecoder.cs │ │ ├── InternalAttribute.cs │ │ ├── MemoryAttribute.cs │ │ ├── MemoryFileUpload.cs │ │ ├── MixedAttribute.cs │ │ ├── MixedFileUpload.cs │ │ ├── MultiPartStatus.cs │ │ └── NotEnoughDataDecoderException.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── QueryStringDecoder.cs │ ├── QueryStringEncoder.cs │ ├── ThrowHelper.cs │ ├── UrlEncoder.cs │ └── WebSockets │ │ ├── BinaryWebSocketFrame.cs │ │ ├── CloseWebSocketFrame.cs │ │ ├── ContinuationWebSocketFrame.cs │ │ ├── Extensions │ │ ├── Compression │ │ │ ├── DeflateDecoder.cs │ │ │ ├── DeflateEncoder.cs │ │ │ ├── DeflateFrameClientExtensionHandshaker.cs │ │ │ ├── DeflateFrameServerExtensionHandshaker.cs │ │ │ ├── PerFrameDeflateDecoder.cs │ │ │ ├── PerFrameDeflateEncoder.cs │ │ │ ├── PerMessageDeflateClientExtensionHandshaker.cs │ │ │ ├── PerMessageDeflateDecoder.cs │ │ │ ├── PerMessageDeflateEncoder.cs │ │ │ ├── PerMessageDeflateServerExtensionHandshaker.cs │ │ │ ├── WebSocketClientCompressionHandler.cs │ │ │ └── WebSocketServerCompressionHandler.cs │ │ ├── IWebSocketClientExtension.cs │ │ ├── IWebSocketClientExtensionHandshaker.cs │ │ ├── IWebSocketExtension.cs │ │ ├── IWebSocketServerExtension.cs │ │ ├── IWebSocketServerExtensionHandshaker.cs │ │ ├── WebSocketClientExtensionHandler.cs │ │ ├── WebSocketExtensionData.cs │ │ ├── WebSocketExtensionDecoder.cs │ │ ├── WebSocketExtensionEncoder.cs │ │ ├── WebSocketExtensionUtil.cs │ │ └── WebSocketServerExtensionHandler.cs │ │ ├── IWebSocketFrameDecoder.cs │ │ ├── IWebSocketFrameEncoder.cs │ │ ├── PingWebSocketFrame.cs │ │ ├── PongWebSocketFrame.cs │ │ ├── TextWebSocketFrame.cs │ │ ├── Utf8FrameValidator.cs │ │ ├── Utf8Validator.cs │ │ ├── WebSocket00FrameDecoder.cs │ │ ├── WebSocket00FrameEncoder.cs │ │ ├── WebSocket07FrameDecoder.cs │ │ ├── WebSocket07FrameEncoder.cs │ │ ├── WebSocket08FrameDecoder.cs │ │ ├── WebSocket08FrameEncoder.cs │ │ ├── WebSocket13FrameDecoder.cs │ │ ├── WebSocket13FrameEncoder.cs │ │ ├── WebSocketChunkedInput.cs │ │ ├── WebSocketClientHandshaker.cs │ │ ├── WebSocketClientHandshaker00.cs │ │ ├── WebSocketClientHandshaker07.cs │ │ ├── WebSocketClientHandshaker08.cs │ │ ├── WebSocketClientHandshaker13.cs │ │ ├── WebSocketClientHandshakerFactory.cs │ │ ├── WebSocketClientProtocolHandler.cs │ │ ├── WebSocketClientProtocolHandshakeHandler.cs │ │ ├── WebSocketFrame.cs │ │ ├── WebSocketFrameAggregator.cs │ │ ├── WebSocketHandshakeException.cs │ │ ├── WebSocketProtocolHandler.cs │ │ ├── WebSocketScheme.cs │ │ ├── WebSocketServerHandshaker.cs │ │ ├── WebSocketServerHandshaker00.cs │ │ ├── WebSocketServerHandshaker07.cs │ │ ├── WebSocketServerHandshaker08.cs │ │ ├── WebSocketServerHandshaker13.cs │ │ ├── WebSocketServerHandshakerFactory.cs │ │ ├── WebSocketServerProtocolHandler.cs │ │ ├── WebSocketServerProtocolHandshakeHandler.cs │ │ ├── WebSocketUtil.cs │ │ └── WebSocketVersion.cs ├── DotNetty.Codecs.Mqtt │ ├── DotNetty.Codecs.Mqtt.csproj │ ├── MqttDecoder.cs │ ├── MqttEncoder.cs │ ├── Packets │ │ ├── ConnAckPacket.cs │ │ ├── ConnectPacket.cs │ │ ├── ConnectReturnCode.cs │ │ ├── DisconnectPacket.cs │ │ ├── Packet.cs │ │ ├── PacketType.cs │ │ ├── PacketWithId.cs │ │ ├── PingReqPacket.cs │ │ ├── PingRespPacket.cs │ │ ├── PubAckPacket.cs │ │ ├── PubCompPacket.cs │ │ ├── PubRecPacket.cs │ │ ├── PubRelPacket.cs │ │ ├── PublishPacket.cs │ │ ├── QualityOfService.cs │ │ ├── SubAckPacket.cs │ │ ├── SubscribePacket.cs │ │ ├── SubscriptionRequest.cs │ │ ├── UnsubAckPacket.cs │ │ └── UnsubscribePacket.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── Signatures.cs │ └── Util.cs ├── DotNetty.Codecs.Protobuf │ ├── DotNetty.Codecs.Protobuf.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ProtobufDecoder.cs │ └── ProtobufEncoder.cs ├── DotNetty.Codecs.ProtocolBuffers │ ├── DotNetty.Codecs.ProtocolBuffers.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ProtobufDecoder.cs │ └── ProtobufEncoder.cs ├── DotNetty.Codecs.Redis │ ├── DotNetty.Codecs.Redis.csproj │ ├── FixedRedisMessagePool.cs │ ├── IRedisMessagePool.cs │ ├── Messages │ │ ├── AbstractStringRedisMessage.cs │ │ ├── ArrayHeaderRedisMessage.cs │ │ ├── ArrayRedisMessage.cs │ │ ├── BulkStringHeaderRedisMessage.cs │ │ ├── DefaultBulkStringRedisContent.cs │ │ ├── DefaultLastBulkStringRedisContent.cs │ │ ├── ErrorRedisMessage.cs │ │ ├── FullBulkStringRedisMessage.cs │ │ ├── IArrayRedisMessage.cs │ │ ├── IBulkStringRedisContent.cs │ │ ├── IFullBulkStringRedisMessage.cs │ │ ├── ILastBulkStringRedisContent.cs │ │ ├── IRedisMessage.cs │ │ ├── InlineCommandRedisMessage.cs │ │ ├── IntegerRedisMessage.cs │ │ ├── RedisMessageType.cs │ │ └── SimpleStringRedisMessage.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RedisArrayAggregator.cs │ ├── RedisBulkStringAggregator.cs │ ├── RedisCodecException.cs │ ├── RedisCodecUtil.cs │ ├── RedisConstants.cs │ ├── RedisDecoder.cs │ └── RedisEncoder.cs ├── DotNetty.Codecs │ ├── Base64 │ │ ├── Base64.cs │ │ ├── Base64Decoder.cs │ │ ├── Base64Dialect.cs │ │ └── Base64Encoder.cs │ ├── ByteToMessageDecoder.cs │ ├── CharSequenceValueConverter.cs │ ├── CodecException.cs │ ├── Compression │ │ ├── Adler32.cs │ │ ├── CRC32.cs │ │ ├── CompressionException.cs │ │ ├── DecompressionException.cs │ │ ├── Deflate.cs │ │ ├── Deflater.cs │ │ ├── GZIPException.cs │ │ ├── GZIPHeader.cs │ │ ├── IChecksum.cs │ │ ├── InfBlocks.cs │ │ ├── InfCodes.cs │ │ ├── InfTree.cs │ │ ├── Inflate.cs │ │ ├── Inflater.cs │ │ ├── JZlib.cs │ │ ├── JZlibDecoder.cs │ │ ├── JZlibEncoder.cs │ │ ├── StaticTree.cs │ │ ├── Tree.cs │ │ ├── ZStream.cs │ │ ├── ZlibCodecFactory.cs │ │ ├── ZlibDecoder.cs │ │ ├── ZlibEncoder.cs │ │ ├── ZlibUtil.cs │ │ └── ZlibWrapper.cs │ ├── CorruptedFrameException.cs │ ├── DatagramPacketDecoder.cs │ ├── DatagramPacketEncoder.cs │ ├── DateFormatter.cs │ ├── DecoderException.cs │ ├── DecoderResult.cs │ ├── DefaultHeaders.cs │ ├── DelimiterBasedFrameDecoder.cs │ ├── Delimiters.cs │ ├── DotNetty.Codecs.csproj │ ├── EncoderException.cs │ ├── HeadersUtils.cs │ ├── IDecoderResultProvider.cs │ ├── IHeaders.cs │ ├── INameValidator.cs │ ├── IValueConverter.cs │ ├── Json │ │ └── JsonObjectDecoder.cs │ ├── LengthFieldBasedFrameDecoder.cs │ ├── LengthFieldPrepender.cs │ ├── LineBasedFrameDecoder.cs │ ├── MessageAggregationException.cs │ ├── MessageAggregator.cs │ ├── MessageToByteEncoder.cs │ ├── MessageToMessageCodec.cs │ ├── MessageToMessageDecoder.cs │ ├── MessageToMessageEncoder.cs │ ├── NullNameValidator.cs │ ├── PrematureChannelClosureException.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── Protobuf │ │ ├── ProtobufVarint32FrameDecoder.cs │ │ └── ProtobufVarint32LengthFieldPrepender.cs │ ├── ReplayingDecoder.cs │ ├── Strings │ │ ├── StringDecoder.cs │ │ └── StringEncoder.cs │ ├── TooLongFrameException.cs │ └── UnsupportedMessageTypeException.cs ├── DotNetty.Common │ ├── Concurrency │ │ ├── AbstractEventExecutor.cs │ │ ├── AbstractEventExecutorGroup.cs │ │ ├── AbstractExecutorService.cs │ │ ├── AbstractScheduledEventExecutor.cs │ │ ├── ActionScheduledAsyncTask.cs │ │ ├── ActionScheduledTask.cs │ │ ├── ExecutionEnvironment.cs │ │ ├── ExecutorTaskScheduler.cs │ │ ├── ICallable`T.cs │ │ ├── IEventExecutor.cs │ │ ├── IEventExecutorGroup.cs │ │ ├── IExecutor.cs │ │ ├── IExecutorService.cs │ │ ├── IRunnable.cs │ │ ├── IScheduledExecutorService.cs │ │ ├── IScheduledRunnable.cs │ │ ├── IScheduledTask.cs │ │ ├── RejectedExecutionException.cs │ │ ├── RunnableScheduledTask.cs │ │ ├── ScheduledAsyncTask.cs │ │ ├── ScheduledTask.cs │ │ ├── SingleThreadEventExecutor.cs │ │ ├── StateActionScheduledAsyncTask.cs │ │ ├── StateActionScheduledTask.cs │ │ ├── StateActionWithContextScheduledAsyncTask.cs │ │ ├── StateActionWithContextScheduledTask.cs │ │ └── TaskCompletionSource.cs │ ├── DotNetty.Common.csproj │ ├── FastThreadLocal.cs │ ├── IReferenceCounted.cs │ ├── IResourceLeakHint.cs │ ├── IResourceLeakTracker.cs │ ├── Internal │ │ ├── AbstractQueue.cs │ │ ├── AppendableCharSequence.cs │ │ ├── CompatibleConcurrentQueue.cs │ │ ├── ConcurrentCircularArrayQueue.cs │ │ ├── DefaultPlatformImplementation.cs │ │ ├── EmptyArrays.cs │ │ ├── IAppendable.cs │ │ ├── IDeque.cs │ │ ├── IPlatform.cs │ │ ├── IQueue.cs │ │ ├── Logging │ │ │ ├── AbstractInternalLogger.cs │ │ │ ├── DefaultEventSource.cs │ │ │ ├── EventSourceLogger.cs │ │ │ ├── EventSourceLoggerProvider.cs │ │ │ ├── FormattingTuple.cs │ │ │ ├── GenericLogger.cs │ │ │ ├── IInternalLogger.cs │ │ │ ├── InternalLogLevel.cs │ │ │ ├── InternalLoggerFactory.cs │ │ │ └── MessageFormatter.cs │ │ ├── MacAddressUtil.cs │ │ ├── MathUtil.cs │ │ ├── MpscArrayQueue.cs │ │ ├── Platform.cs │ │ ├── PlatformDependent.cs │ │ ├── PlatformDependent0.cs │ │ ├── PlatformProvider.cs │ │ ├── RefArrayAccessUtil.cs │ │ ├── SpscLinkedQueue.cs │ │ └── SystemPropertyUtil.cs │ ├── InternalThreadLocalMap.cs │ ├── PreciseTimeSpan.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── ResourceLeakDetector.cs │ ├── ThreadDeathWatcher.cs │ ├── ThreadLocalObjectList.cs │ ├── ThreadLocalPool.cs │ └── Utilities │ │ ├── AbstractConstant.cs │ │ ├── AbstractReferenceCounted.cs │ │ ├── ActionTimerTask.cs │ │ ├── ArrayExtensions.cs │ │ ├── AsciiString.cs │ │ ├── AtomicReference.cs │ │ ├── AttributeKey.cs │ │ ├── BitOps.cs │ │ ├── ByteProcessor.cs │ │ ├── ByteProcessorUtils.cs │ │ ├── CharSequenceEnumerator.cs │ │ ├── CharUtil.cs │ │ ├── ConstantPool.cs │ │ ├── DebugExtensions.cs │ │ ├── DefaultAttributeMap.cs │ │ ├── HashedWheelTimer.cs │ │ ├── IAttribute.cs │ │ ├── IAttributeMap.cs │ │ ├── ICharSequence.cs │ │ ├── IConstant.cs │ │ ├── IHashingStrategy.cs │ │ ├── ITimeout.cs │ │ ├── ITimer.cs │ │ ├── ITimerTask.cs │ │ ├── IllegalReferenceCountException.cs │ │ ├── IntegerExtensions.cs │ │ ├── MediumUtil.cs │ │ ├── NetUtil.cs │ │ ├── PriorityQueue.cs │ │ ├── RandomExtensions.cs │ │ ├── ReferenceCountUtil.cs │ │ ├── ReferenceEqualityComparer.cs │ │ ├── Signal.cs │ │ ├── StringBuilderCharSequence.cs │ │ ├── StringCharSequence.cs │ │ ├── StringUtil.cs │ │ ├── TaskEx.cs │ │ ├── ThreadExtensions.cs │ │ └── TimeUtil.cs ├── DotNetty.Handlers │ ├── DotNetty.Handlers.csproj │ ├── Flow │ │ └── FlowControlHandler.cs │ ├── Logging │ │ ├── LogLevel.cs │ │ ├── LogLevelExtensions.cs │ │ └── LoggingHandler.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── Streams │ │ ├── ChunkedStream.cs │ │ ├── ChunkedWriteHandler.cs │ │ └── IChunkedInput.cs │ ├── Timeout │ │ ├── IdleState.cs │ │ ├── IdleStateEvent.cs │ │ ├── IdleStateHandler.cs │ │ ├── ReadTimeoutException.cs │ │ ├── ReadTimeoutHandler.cs │ │ ├── TimeoutException.cs │ │ ├── WriteTimeoutException.cs │ │ └── WriteTimeoutHandler.cs │ └── Tls │ │ ├── ClientTlsSettings.cs │ │ ├── NotSslRecordException.cs │ │ ├── ServerTlsSettings.cs │ │ ├── ServerTlsSniSettings.cs │ │ ├── SniHandler.cs │ │ ├── TlsHandler.MediationStream.Net.cs │ │ ├── TlsHandler.MediationStream.cs │ │ ├── TlsHandler.MediationStreamBase.cs │ │ ├── TlsHandler.cs │ │ ├── TlsHandshakeCompletionEvent.cs │ │ ├── TlsSettings.cs │ │ └── TlsUtils.cs ├── DotNetty.Transport.Libuv │ ├── DispatcherEventLoop.cs │ ├── DispatcherEventLoopGroup.cs │ ├── DotNetty.Transport.Libuv.csproj │ ├── EventLoop.cs │ ├── EventLoopGroup.cs │ ├── LoopExecutor.cs │ ├── Native │ │ ├── Async.cs │ │ ├── ConnectRequest.cs │ │ ├── Loop.cs │ │ ├── NativeHandle.cs │ │ ├── NativeMethods.cs │ │ ├── NativeRequest.cs │ │ ├── OperationException.cs │ │ ├── Pipe.cs │ │ ├── PipeHandle.cs │ │ ├── PipeListener.cs │ │ ├── PlatformApi.cs │ │ ├── ReadOperation.cs │ │ ├── RemoteConnection.cs │ │ ├── Tcp.cs │ │ ├── TcpConnect.cs │ │ ├── TcpHandle.cs │ │ ├── TcpListener.cs │ │ ├── Timer.cs │ │ ├── UnixApi.cs │ │ ├── WindowsApi.cs │ │ └── WriteRequest.cs │ ├── NativeChannel.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs │ ├── TcpChannel.cs │ ├── TcpChannelConfig.cs │ ├── TcpServerChannel.cs │ ├── TcpServerChannelConfig.cs │ ├── WorkerEventLoop.cs │ └── WorkerEventLoopGroup.cs ├── DotNetty.Transport │ ├── Bootstrapping │ │ ├── AbstractBootstrap.cs │ │ ├── Bootstrap.cs │ │ ├── DefaultNameResolver.cs │ │ ├── INameResolver.cs │ │ └── ServerBootstrap.cs │ ├── Channels │ │ ├── AbstractChannel.cs │ │ ├── AbstractChannelHandlerContext.cs │ │ ├── AbstractServerChannel.cs │ │ ├── ActionChannelInitializer.cs │ │ ├── AdaptiveRecvByteBufAllocator.cs │ │ ├── AffinitizedEventLoopGroup.cs │ │ ├── AlreadyConnectedException.cs │ │ ├── BatchingPendingWriteQueue.cs │ │ ├── ChannelDuplexHandler.cs │ │ ├── ChannelException.cs │ │ ├── ChannelHandlerAdapter.cs │ │ ├── ChannelInitializer.cs │ │ ├── ChannelMetadata.cs │ │ ├── ChannelOption.cs │ │ ├── ChannelOutboundBuffer.cs │ │ ├── ChannelPipelineException.cs │ │ ├── ClosedChannelException.cs │ │ ├── CombinedChannelDuplexHandler.cs │ │ ├── ConnectException.cs │ │ ├── ConnectTimeoutException.cs │ │ ├── ConnectionPendingException.cs │ │ ├── DefaultAddressedEnvelope.cs │ │ ├── DefaultChannelConfiguration.cs │ │ ├── DefaultChannelHandlerContext.cs │ │ ├── DefaultChannelId.cs │ │ ├── DefaultChannelPipeline.cs │ │ ├── DefaultFileRegion.cs │ │ ├── DefaultMaxMessagesRecvByteBufAllocator.cs │ │ ├── DefaultMessageSizeEstimator.cs │ │ ├── Embedded │ │ │ ├── EmbeddedChannel.cs │ │ │ ├── EmbeddedChannelId.cs │ │ │ ├── EmbeddedEventLoop.cs │ │ │ ├── EmbeddedSocketAddress.cs │ │ │ ├── IEmbeddedChannel.cs │ │ │ └── SingleThreadedEmbeddedChannel.cs │ │ ├── FixedRecvByteBufAllocator.cs │ │ ├── Groups │ │ │ ├── ChannelGroupException.cs │ │ │ ├── ChannelMatchers.cs │ │ │ ├── CombinedEnumerator.cs │ │ │ ├── DefaultChannelGroup.cs │ │ │ ├── DefaultChannelGroupCompletionSource.cs │ │ │ ├── IChannelGroup.cs │ │ │ ├── IChannelGroupTaskCompletionSource.cs │ │ │ └── IChannelMatcher.cs │ │ ├── IAddressedEnvelope.cs │ │ ├── IChannel.cs │ │ ├── IChannelConfiguration.cs │ │ ├── IChannelHandler.cs │ │ ├── IChannelHandlerContext.cs │ │ ├── IChannelId.cs │ │ ├── IChannelPipeline.cs │ │ ├── IChannelUnsafe.cs │ │ ├── IEventLoop.cs │ │ ├── IEventLoopGroup.cs │ │ ├── IFileRegion.cs │ │ ├── IMaxMessagesRecvByteBufAllocator.cs │ │ ├── IMessageSizeEstimator.cs │ │ ├── IMessageSizeEstimatorHandle.cs │ │ ├── IRecvByteBufAllocator.cs │ │ ├── IRecvByteBufAllocatorHandle.cs │ │ ├── IServerChannel.cs │ │ ├── Local │ │ │ ├── LocalAddress.cs │ │ │ ├── LocalChannel.cs │ │ │ ├── LocalChannelRegistry.cs │ │ │ └── LocalServerChannel.cs │ │ ├── MultithreadEventLoopGroup.cs │ │ ├── NotYetConnectedException.cs │ │ ├── PendingWriteQueue.cs │ │ ├── Pool │ │ │ ├── AbstractChannelPoolMap.cs │ │ │ ├── ChannelActiveHealthChecker.cs │ │ │ ├── CountingChannelPoolHandler.cs │ │ │ ├── FixedChannelPool.cs │ │ │ ├── IChannelHealthChecker.cs │ │ │ ├── IChannelPool.cs │ │ │ ├── IChannelPoolHandler.cs │ │ │ ├── IChannelPoolMap.cs │ │ │ └── SimpleChannelPool.cs │ │ ├── SimpleChannelInboundHandler.cs │ │ ├── SingleThreadEventLoop.cs │ │ ├── SkipAttribute.cs │ │ ├── Sockets │ │ │ ├── AbstractSocketByteChannel.cs │ │ │ ├── AbstractSocketChannel.cs │ │ │ ├── AbstractSocketMessageChannel.cs │ │ │ ├── ChannelInputShutdownEvent.cs │ │ │ ├── DatagramPacket.cs │ │ │ ├── DefaultDatagramChannelConfig.cs │ │ │ ├── DefaultServerSocketChannelConfig.cs │ │ │ ├── DefaultSocketChannelConfiguration.cs │ │ │ ├── IDatagramChannel.cs │ │ │ ├── IDatagramChannelConfig.cs │ │ │ ├── IServerSocketChannel.cs │ │ │ ├── IServerSocketChannelConfiguration.cs │ │ │ ├── ISocketChannel.cs │ │ │ ├── ISocketChannelConfiguration.cs │ │ │ ├── SocketChannelAsyncOperation.cs │ │ │ ├── SocketDatagramChannel.cs │ │ │ ├── TcpServerSocketChannel.cs │ │ │ └── TcpSocketChannel.cs │ │ └── Util.cs │ ├── DotNetty.Transport.csproj │ └── Properties │ │ ├── AssemblyInfo.cs │ │ └── Friends.cs └── shared │ └── SharedAssemblyInfo.cs ├── test ├── DotNetty.Buffers.Tests │ ├── AbstractByteBufferAllocatorTests.cs │ ├── AbstractByteBufferTests.cs │ ├── AbstractCompositeByteBufferTests.cs │ ├── AbstractPooledByteBufferTests.cs │ ├── AbstractReferenceCountedByteBufferTests.cs │ ├── AdvancedLeakAwareByteBufferTests.cs │ ├── AdvancedLeakAwareCompositeByteBufferTests.cs │ ├── ByteBufferAllocatorTests.cs │ ├── ByteBufferDerivationTests.cs │ ├── ByteBufferUtilTests.cs │ ├── CompositeByteBufferTests.cs │ ├── ConsolidationTest.cs │ ├── DefaultByteBufferHolderTests.cs │ ├── DotNetty.Buffers.Tests.csproj │ ├── DuplicatedByteBufferTests.cs │ ├── EmptyByteBufferTests.cs │ ├── HeapByteBufferTests.cs │ ├── NoopResourceLeakTracker.cs │ ├── PoolArenaTests.cs │ ├── PooledByteBufferAllocatorTests.cs │ ├── PooledDirectByteBufferTests.cs │ ├── PooledHeapByteBufferTests.cs │ ├── PortionedMemoryStream.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReadOnlyByteBufferStreamTests.cs │ ├── RetainedSlicedByteBufferTests.cs │ ├── SimpleLeakAwareByteBufferTests.cs │ ├── SimpleLeakAwareCompositeByteBufferTests.cs │ ├── SlicedByteBufferTest.cs │ ├── UnpooledByteBufferAllocatorTests.cs │ ├── UnpooledTests.cs │ ├── UnpooledWriteStreamTests.cs │ ├── UnreleaseableByteBufferTests.cs │ ├── UnsafeDirectByteBufferTest.cs │ └── WrappedCompositeByteBufferTests.cs ├── DotNetty.Codecs.Http.Tests │ ├── CombinedHttpHeadersTest.cs │ ├── Cookies │ │ ├── ClientCookieDecoderTest.cs │ │ ├── ClientCookieEncoderTest.cs │ │ ├── ServerCookieDecoderTest.cs │ │ └── ServerCookieEncoderTest.cs │ ├── Cors │ │ ├── CorsConfigTest.cs │ │ └── CorsHandlerTest.cs │ ├── DefaultHttpHeadersTest.cs │ ├── DefaultHttpRequestTest.cs │ ├── DotNetty.Codecs.Http.Tests.csproj │ ├── HttpChunkedInputTest.cs │ ├── HttpClientCodecTest.cs │ ├── HttpClientUpgradeHandlerTest.cs │ ├── HttpContentCompressorTest.cs │ ├── HttpContentDecoderTest.cs │ ├── HttpContentEncoderTest.cs │ ├── HttpHeadersTest.cs │ ├── HttpHeadersTestUtils.cs │ ├── HttpInvalidMessageTest.cs │ ├── HttpObjectAggregatorTest.cs │ ├── HttpRequestDecoderTest.cs │ ├── HttpRequestEncoderTest.cs │ ├── HttpResponseDecoderTest.cs │ ├── HttpResponseEncoderTest.cs │ ├── HttpResponseStatusTest.cs │ ├── HttpServerCodecTest.cs │ ├── HttpServerExpectContinueHandlerTest.cs │ ├── HttpServerKeepAliveHandlerTest.cs │ ├── HttpServerUpgradeHandlerTest.cs │ ├── HttpUtilTest.cs │ ├── Multipart │ │ ├── AbstractMemoryHttpDataTest.cs │ │ ├── DefaultHttpDataFactoryTest.cs │ │ ├── DiskFileUploadTest.cs │ │ ├── HttpPostRequestDecoderTest.cs │ │ ├── HttpPostRequestEncoderTest.cs │ │ ├── MemoryFileUploadTest.cs │ │ ├── file-01.txt │ │ └── file-02.txt │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── QueryStringDecoderTest.cs │ ├── QueryStringEncoderTest.cs │ └── WebSockets │ │ ├── Extensions │ │ ├── Compression │ │ │ ├── DeflateFrameClientExtensionHandshakerTest.cs │ │ │ ├── DeflateFrameServerExtensionHandshakerTest.cs │ │ │ ├── PerFrameDeflateDecoderTest.cs │ │ │ ├── PerFrameDeflateEncoderTest.cs │ │ │ ├── PerMessageDeflateClientExtensionHandshakerTest.cs │ │ │ ├── PerMessageDeflateDecoderTest.cs │ │ │ ├── PerMessageDeflateEncoderTest.cs │ │ │ ├── PerMessageDeflateServerExtensionHandshakerTest.cs │ │ │ └── WebSocketServerCompressionHandlerTest.cs │ │ ├── WebSocketClientExtensionHandlerTest.cs │ │ ├── WebSocketExtensionTestUtil.cs │ │ ├── WebSocketExtensionUtilTest.cs │ │ └── WebSocketServerExtensionHandlerTest.cs │ │ ├── WebSocket00FrameEncoderTest.cs │ │ ├── WebSocket08EncoderDecoderTest.cs │ │ ├── WebSocket08FrameDecoderTest.cs │ │ ├── WebSocketClientHandshaker00Test.cs │ │ ├── WebSocketClientHandshaker07Test.cs │ │ ├── WebSocketClientHandshaker08Test.cs │ │ ├── WebSocketClientHandshaker13Test.cs │ │ ├── WebSocketClientHandshakerTest.cs │ │ ├── WebSocketFrameAggregatorTest.cs │ │ ├── WebSocketHandshakeHandOverTest.cs │ │ ├── WebSocketProtocolHandlerTest.cs │ │ ├── WebSocketRequestBuilder.cs │ │ ├── WebSocketServerHandshaker00Test.cs │ │ ├── WebSocketServerHandshaker08Test.cs │ │ ├── WebSocketServerHandshaker13Test.cs │ │ ├── WebSocketServerHandshakerFactoryTest.cs │ │ └── WebSocketServerProtocolHandlerTest.cs ├── DotNetty.Codecs.Mqtt.Tests │ ├── DotNetty.Codecs.Mqtt.Tests.csproj │ ├── MqttCodecTests.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── DotNetty.Codecs.Protobuf.Tests │ ├── Addressbook.cs │ ├── Addressbook.proto │ ├── DotNetty.Codecs.Protobuf.Tests.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── RoundTripTests.cs ├── DotNetty.Codecs.ProtocolBuffers.Tests │ ├── AddressBook.proto │ ├── Addressbook.cs │ ├── DotNetty.Codecs.ProtocolBuffers.Tests.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ └── RoundTripTests.cs ├── DotNetty.Codecs.Redis.Tests │ ├── DotNetty.Codecs.Redis.Tests.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── RedisCodecTestUtil.cs │ ├── RedisDecoderTest.cs │ └── RedisEncoderTests.cs ├── DotNetty.Codecs.Tests │ ├── Base64Test.cs │ ├── DatagramPacketDecoderTest.cs │ ├── DatagramPacketEncoderTest.cs │ ├── DateFormatterTest.cs │ ├── DefaultHeadersTest.cs │ ├── DotNetty.Codecs.Tests.csproj │ ├── Frame │ │ ├── LengthFieldBasedFrameDecoderTests.cs │ │ └── LengthFieldPrependerTest.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── Protobuf │ │ ├── ProtobufVarint32FrameDecoderTest.cs │ │ ├── ProtobufVarint32LengthFieldPrependerTests.cs │ │ └── TestUtil.cs ├── DotNetty.Common.Tests │ ├── Concurrency │ │ └── SingleThreadEventExecutorTests.cs │ ├── DotNetty.Common.Tests.csproj │ ├── Internal │ │ └── Logging │ │ │ └── InternalLoggerFactoryTest.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ThreadLocalPoolTest.cs │ ├── Utilities │ │ ├── AsciiStringCharacterTest.cs │ │ ├── HashedWheelTimerTest.cs │ │ └── PriorityQueueTest.cs │ └── app.config ├── DotNetty.Handlers.Tests │ ├── AsIsWriteStrategy.cs │ ├── BatchingWriteStrategy.cs │ ├── DotNetty.Handlers.Tests.csproj │ ├── Flow │ │ └── FlowControlHandlerTest.cs │ ├── IWriteStrategy.cs │ ├── IdleStateHandlerTest.cs │ ├── MediationStream.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SniHandlerTest.cs │ └── TlsHandlerTest.cs ├── DotNetty.Microbench │ ├── Allocators │ │ ├── AbstractByteBufferAllocatorBenchmark.cs │ │ ├── PooledByteBufferAllocatorBenchmark.cs │ │ ├── PooledHeapByteBufferAllocatorBenchmark.cs │ │ └── UnpooledByteBufferAllocatorBenchmark.cs │ ├── Buffers │ │ ├── ByteBufUtilBenchmark.cs │ │ ├── ByteBufferBenchmark.cs │ │ ├── PooledByteBufferBenchmark.cs │ │ └── UnpooledByteBufferBenchmark.cs │ ├── Codecs │ │ └── DateFormatterBenchmark.cs │ ├── Common │ │ └── AsciiStringBenchmark.cs │ ├── Concurrency │ │ ├── FastThreadLocalBenchmark.cs │ │ └── SingleThreadEventExecutorBenchmark.cs │ ├── DotNetty.Microbench.csproj │ ├── Headers │ │ ├── ExampleHeaders.cs │ │ └── HeadersBenchmark.cs │ ├── Http │ │ ├── ClientCookieDecoderBenchmark.cs │ │ ├── HttpRequestDecoderBenchmark.cs │ │ ├── HttpRequestEncoderInsertBenchmark.cs │ │ └── WriteBytesVsShortOrMediumBenchmark.cs │ ├── Internal │ │ └── PlatformDependentBenchmark.cs │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── DotNetty.Tests.Common │ ├── AssertEx.cs │ ├── ChannelExtensions.cs │ ├── Disposable.cs │ ├── DotNetty.Tests.Common.csproj │ ├── EnumerableExtensions.cs │ ├── LogTestHelper.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReadListeningHandler.cs │ ├── TaskExtensions.cs │ ├── TestBase.cs │ ├── TestResourceHelper.cs │ ├── XUnitOutputLogger.cs │ ├── XUnitOutputLoggerProvider.cs │ └── app.config ├── DotNetty.Tests.End2End │ ├── DotNetty.Tests.End2End.csproj │ ├── EchoChannelHandler.cs │ ├── End2EndTests.cs │ ├── ExceptionCatchHandler.cs │ └── app.config ├── DotNetty.Transport.Libuv.Tests │ ├── AutoReadTests.cs │ ├── BufReleaseTests.cs │ ├── CloseForciblyTests.cs │ ├── CompositeBufferGatheringWriteTests.cs │ ├── ConnectTests.cs │ ├── ConnectionAttemptTests.cs │ ├── DetectPeerCloseWithoutReadTests.cs │ ├── DotNetty.Transport.Libuv.Tests.csproj │ ├── EchoTests.cs │ ├── EventLoopTests.cs │ ├── ExceptionHandlingTests.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── ReadPendingTests.cs │ ├── ResetTests.cs │ ├── TestUtil.cs │ └── WriteBeforeRegisteredTests.cs ├── DotNetty.Transport.Tests.Performance │ ├── DotNetty.Transport.Tests.Performance.csproj │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Sockets │ │ ├── SocketDatagramChannelPerfSpecs.cs │ │ ├── TcpSocketChannelInboundOnlyPerfSpec.cs │ │ └── TcpSocketChannelPerfSpec.cs │ ├── Transport │ │ ├── AbstractPingPongPerfSpecs.cs │ │ ├── AbstractPumpPerfSpecs.cs │ │ ├── LibuvPingPongPerfSpecs.cs │ │ ├── LibuvPumpPerfSpecs.cs │ │ ├── SocketPingPongPerfSpecs.cs │ │ └── SocketPumpPerfSpecs.cs │ └── Utilities │ │ ├── CounterHandlerInbound.cs │ │ ├── CounterHandlerOutbound.cs │ │ ├── IReadFinishedSignal.cs │ │ ├── ManualResetEventSlimReadFinishedSignal.cs │ │ ├── ReadFinishedHandler.cs │ │ ├── SimpleReadFinishedSignal.cs │ │ └── TaskCompletionSourceFinishedSignal.cs └── DotNetty.Transport.Tests │ ├── Channel │ ├── DefaulChannelIdTest.cs │ ├── Embedded │ │ └── EmbeddedChannelTest.cs │ ├── Pool │ │ ├── FixedChannelPoolTest.cs │ │ └── SimpleChannelPoolTest.cs │ └── Sockets │ │ ├── NetUtil.cs │ │ ├── SocketDatagramChannelMulticastTest.cs │ │ └── SocketDatagramChannelUnicastTest.cs │ ├── DotNetty.Transport.Tests.csproj │ └── Properties │ └── AssemblyInfo.cs └── tools └── AddCopyrightHeaderToSourceFiles.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | *.doc diff=astextplain 2 | *.DOC diff=astextplain 3 | *.docx diff=astextplain 4 | *.DOCX diff=astextplain 5 | *.dot diff=astextplain 6 | *.DOT diff=astextplain 7 | *.pdf diff=astextplain 8 | *.PDF diff=astextplain 9 | *.rtf diff=astextplain 10 | *.RTF diff=astextplain 11 | 12 | *.jpg binary 13 | *.png binary 14 | *.gif binary 15 | 16 | *.cs text=auto diff=csharp 17 | *.vb text=auto 18 | *.resx text=auto 19 | *.c text=auto 20 | *.cpp text=auto 21 | *.cxx text=auto 22 | *.h text=auto 23 | *.hxx text=auto 24 | *.py text=auto 25 | *.rb text=auto 26 | *.java text=auto 27 | *.html text=auto 28 | *.htm text=auto 29 | *.css text=auto 30 | *.scss text=auto 31 | *.sass text=auto 32 | *.less text=auto 33 | *.js text=auto 34 | *.lisp text=auto 35 | *.clj text=auto 36 | *.sql text=auto 37 | *.php text=auto 38 | *.lua text=auto 39 | *.m text=auto 40 | *.asm text=auto 41 | *.erl text=auto 42 | *.fs text=auto 43 | *.fsx text=auto 44 | *.hs text=auto 45 | *.txt eol=crlf 46 | 47 | *.csproj text=auto 48 | *.vbproj text=auto 49 | *.fsproj text=auto 50 | *.dbproj text=auto 51 | *.sln text=auto eol=crlf 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Oo]bj/ 2 | [Bb]in/ 3 | TestResults/ 4 | PerfResults/ 5 | .nuget/ 6 | .fake/ 7 | _ReSharper.*/ 8 | .idea/ 9 | *.sln.iml 10 | packages/ 11 | artifacts/ 12 | PublishProfiles/ 13 | *.user 14 | *.suo 15 | *.cache 16 | *.docstates 17 | _ReSharper.* 18 | nuget.exe 19 | *net45.csproj 20 | *net451.csproj 21 | *k10.csproj 22 | *.psess 23 | *.vsp 24 | *.pidb 25 | *.userprefs 26 | *DS_Store 27 | *.ncrunchsolution 28 | *.*sdf 29 | *.ipch 30 | *.sln.ide 31 | *.lock.json 32 | *.db 33 | .vs/ 34 | [Tt]ools/Cake.* 35 | [Tt]ools/NBench.* 36 | [Tt]ools/NBench 37 | /build/ 38 | .dotnet/ 39 | DotNetty.*.nuget.targets 40 | *.exe -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": ".NET Core Launch (console)", 6 | "type": "coreclr", 7 | "request": "launch", 8 | "preLaunchTask": "build", 9 | "program": "${workspaceRoot}/bin/Debug//", 10 | "args": [], 11 | "cwd": "${workspaceRoot}", 12 | "externalConsole": false, 13 | "stopAtEntry": false, 14 | "internalConsoleOptions": "openOnSessionStart" 15 | }, 16 | { 17 | "name": ".NET Core Attach", 18 | "type": "coreclr", 19 | "request": "attach", 20 | "processId": "${command.pickProcess}" 21 | } 22 | ] 23 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "dotnet", 4 | "isShellCommand": true, 5 | "args": [], 6 | "tasks": [ 7 | { 8 | "taskName": "msbuild", 9 | "args": [ 10 | "dotnetty.sln" 11 | ], 12 | "isBuildCommand": true, 13 | "problemMatcher": "$msCompile" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /Directory.Build.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /DotNetty.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/DotNetty.snk -------------------------------------------------------------------------------- /after.DotNetty.sln.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 0.7.0.{build} 2 | pull_requests: 3 | do_not_increment_build_number: true 4 | image: Visual Studio 2022 5 | build_script: 6 | - cmd: powershell .\build.ps1 -target PR 7 | test: off 8 | deploy: off 9 | notifications: 10 | - provider: GitHubPullRequest 11 | auth_token: 12 | secure: SYDAZL544to3SpNef6qb6HMYCgIr07XkNIRnS/BUem8ahAXIebAzd6LnAlZg1YSA 13 | on_build_success: true 14 | on_build_failure: true 15 | on_build_status_changed: true -------------------------------------------------------------------------------- /examples/Discard.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "host": "127.0.0.1", 4 | "port": "8007", 5 | "size": "256" 6 | } -------------------------------------------------------------------------------- /examples/Discard.Server/DiscardServerHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Discard.Server 5 | { 6 | using System; 7 | using DotNetty.Transport.Channels; 8 | 9 | public class DiscardServerHandler : SimpleChannelInboundHandler 10 | { 11 | protected override void ChannelRead0(IChannelHandlerContext context, object message) 12 | { 13 | } 14 | 15 | public override void ExceptionCaught(IChannelHandlerContext ctx, Exception e) 16 | { 17 | Console.WriteLine("{0}", e.ToString()); 18 | ctx.CloseAsync(); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /examples/Discard.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "port": "8007" 4 | } -------------------------------------------------------------------------------- /examples/Echo.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "host": "127.0.0.1", 4 | "port": "8007", 5 | "size": "256" 6 | } -------------------------------------------------------------------------------- /examples/Echo.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "port": "8007", 4 | "libuv": "true" 5 | } -------------------------------------------------------------------------------- /examples/Examples.Common/Examples.Common.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net472;net5.0;net6.0 4 | 2.0.3 5 | false 6 | Debug;Release;Package 7 | AnyCPU 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/Examples.Common/ServerSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Examples.Common 5 | { 6 | public static class ServerSettings 7 | { 8 | public static bool IsSsl 9 | { 10 | get 11 | { 12 | string ssl = ExampleHelper.Configuration["ssl"]; 13 | return !string.IsNullOrEmpty(ssl) && bool.Parse(ssl); 14 | } 15 | } 16 | 17 | public static int Port => int.Parse(ExampleHelper.Configuration["port"]); 18 | 19 | public static bool UseLibuv 20 | { 21 | get 22 | { 23 | string libuv = ExampleHelper.Configuration["libuv"]; 24 | return !string.IsNullOrEmpty(libuv) && bool.Parse(libuv); 25 | } 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /examples/Factorial.Client/ClientSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Factorial.Client 5 | { 6 | using Examples.Common; 7 | 8 | public class ClientSettings : Examples.Common.ClientSettings 9 | { 10 | public static int Count => int.Parse(ExampleHelper.Configuration["count"]); 11 | } 12 | } -------------------------------------------------------------------------------- /examples/Factorial.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "host": "127.0.0.1", 4 | "port": "8007", 5 | "size": "256", 6 | "count": "100" 7 | } -------------------------------------------------------------------------------- /examples/Factorial.Server/FactorialServerHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Factorial.Server 5 | { 6 | using System; 7 | using System.Numerics; 8 | using DotNetty.Transport.Channels; 9 | 10 | public class FactorialServerHandler : SimpleChannelInboundHandler 11 | { 12 | BigInteger lastMultiplier = new BigInteger(1); 13 | BigInteger factorial = new BigInteger(1); 14 | 15 | protected override void ChannelRead0(IChannelHandlerContext ctx, BigInteger msg) 16 | { 17 | this.lastMultiplier = msg; 18 | this.factorial *= msg; 19 | ctx.WriteAndFlushAsync(this.factorial); 20 | } 21 | 22 | public override void ChannelInactive(IChannelHandlerContext ctx) => Console.WriteLine("Factorial of {0} is: {1}", this.lastMultiplier, this.factorial); 23 | 24 | public override void ExceptionCaught(IChannelHandlerContext ctx, Exception e) => ctx.CloseAsync(); 25 | } 26 | } -------------------------------------------------------------------------------- /examples/Factorial.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "port": "8007" 4 | } -------------------------------------------------------------------------------- /examples/Factorial/Factorial.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | netstandard2.0;net472;net5.0;net6.0 4 | 2.0.3 5 | false 6 | Debug;Release;Package 7 | AnyCPU 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /examples/HttpServer/MessageBody.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace HttpServer 5 | { 6 | sealed class MessageBody 7 | { 8 | public MessageBody(string message) 9 | { 10 | this.Message = message; 11 | } 12 | 13 | public string Message { get; } 14 | 15 | public string ToJsonFormat() => "{" + $"\"{nameof(MessageBody)}\" :" + "{" + $"\"{nameof(this.Message)}\"" + " :\"" + this.Message + "\"}" +"}"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /examples/HttpServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | // General Information about an assembly is controlled through the following 8 | // set of attributes. Change these attribute values to modify the information 9 | // associated with an assembly. 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("HttpWebServer")] 13 | [assembly: AssemblyTrademark("")] 14 | 15 | // Setting ComVisible to false makes the types in this assembly not visible 16 | // to COM components. If you need to access a type in this assembly from 17 | // COM, set the ComVisible attribute to true on that type. 18 | [assembly: ComVisible(false)] 19 | 20 | // The following GUID is for the ID of the typelib if this project is exposed to COM 21 | [assembly: Guid("d4efc310-c3a7-42a2-bc9c-aa9cce3d1c63")] 22 | -------------------------------------------------------------------------------- /examples/HttpServer/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": "7686", 3 | "libuv": "true" 4 | } -------------------------------------------------------------------------------- /examples/QuoteOfTheMoment.Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("QuoteOfTheMoment.Client")] 14 | [assembly: AssemblyTrademark("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("81aa23b3-e975-403c-8c90-0aa0e572b539")] 23 | -------------------------------------------------------------------------------- /examples/QuoteOfTheMoment.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": "7686" 3 | } -------------------------------------------------------------------------------- /examples/QuoteOfTheMoment.Server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("QuoteOfTheMoment.Server")] 14 | [assembly: AssemblyTrademark("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("5e6f211f-a215-409c-8a6d-5ac0251f66b5")] 23 | -------------------------------------------------------------------------------- /examples/QuoteOfTheMoment.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": "7686" 3 | } -------------------------------------------------------------------------------- /examples/SecureChat.Client/SecureChatClientHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace SecureChat.Client 5 | { 6 | using System; 7 | using DotNetty.Transport.Channels; 8 | 9 | public class SecureChatClientHandler : SimpleChannelInboundHandler 10 | { 11 | protected override void ChannelRead0(IChannelHandlerContext contex, string msg) => Console.WriteLine(msg); 12 | 13 | public override void ExceptionCaught(IChannelHandlerContext contex, Exception e) 14 | { 15 | Console.WriteLine(DateTime.Now.Millisecond); 16 | Console.WriteLine(e.StackTrace); 17 | contex.CloseAsync(); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /examples/SecureChat.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "host": "127.0.0.1", 4 | "port": "8007" 5 | } -------------------------------------------------------------------------------- /examples/SecureChat.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "port": "8007" 4 | } -------------------------------------------------------------------------------- /examples/Telnet.Client/TelnetClientHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace Telnet.Client 5 | { 6 | using System; 7 | using DotNetty.Transport.Channels; 8 | 9 | public class TelnetClientHandler : SimpleChannelInboundHandler 10 | { 11 | protected override void ChannelRead0(IChannelHandlerContext contex, string msg) 12 | { 13 | Console.WriteLine(msg); 14 | } 15 | 16 | public override void ExceptionCaught(IChannelHandlerContext contex, Exception e) 17 | { 18 | Console.WriteLine(DateTime.Now.Millisecond); 19 | Console.WriteLine("{0}", e.StackTrace); 20 | contex.CloseAsync(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /examples/Telnet.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "host": "127.0.0.1", 4 | "port": "8007", 5 | "size": "256" 6 | } -------------------------------------------------------------------------------- /examples/Telnet.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "true", 3 | "port": "8007" 4 | } -------------------------------------------------------------------------------- /examples/UWPEcho.Client/App.xaml: -------------------------------------------------------------------------------- 1 |  7 | 8 | 9 | -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/StoreLogo.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /examples/UWPEcho.Client/UWPEcho.Client_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/examples/UWPEcho.Client/UWPEcho.Client_TemporaryKey.pfx -------------------------------------------------------------------------------- /examples/UWPEcho.Client/project.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "Microsoft.Extensions.Logging": "1.1.0", 4 | "Microsoft.Extensions.Logging.Abstractions": "1.1.0", 5 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" 6 | }, 7 | "frameworks": { 8 | "uap10.0": {} 9 | }, 10 | "runtimes": { 11 | "win10-arm": {}, 12 | "win10-arm-aot": {}, 13 | "win10-x86": {}, 14 | "win10-x86-aot": {}, 15 | "win10-x64": {}, 16 | "win10-x64-aot": {} 17 | } 18 | } -------------------------------------------------------------------------------- /examples/UWPEcho.Client/readme.md: -------------------------------------------------------------------------------- 1 | # UWPEcho.Client 2 | 3 | This example connects to the Echo.Server with SSL, using the StreamSocketChannel class -------------------------------------------------------------------------------- /examples/WebSockets.Client/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ssl": "false", 3 | "host": "127.0.0.1", 4 | "port": "8080", 5 | "path": "/websocket", 6 | "libuv": "true" 7 | } -------------------------------------------------------------------------------- /examples/WebSockets.Server/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "port": "8080", 3 | "libuv": "true" 4 | } -------------------------------------------------------------------------------- /shared/contoso.com.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/shared/contoso.com.pfx -------------------------------------------------------------------------------- /shared/dotnetty.com.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Azure/DotNetty/78c5757062a9eb62e2aab2bbb35d3983710f9651/shared/dotnetty.com.pfx -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug;Release;Package 6 | AnyCPU 7 | true 8 | pdbonly 9 | True 10 | true 11 | 12 | 13 | pdbonly 14 | true 15 | $(SolutionDir)build_output\packages 16 | True 17 | true 18 | 19 | 0.7.6 20 | $(PackageVersion) 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/DotNetty.Buffers/ByteOrder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | public enum ByteOrder 7 | { 8 | /// 9 | /// Default on most Windows systems 10 | /// 11 | LittleEndian = 0, 12 | BigEndian = 1 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotNetty.Buffers/IByteBufferAllocatorMetric.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | public interface IByteBufferAllocatorMetric 7 | { 8 | /// 9 | /// Returns the number of bytes of heap memory used by a {@link ByteBufAllocator} or {@code -1} if unknown. 10 | /// 11 | long UsedHeapMemory { get; } 12 | 13 | /// 14 | /// Returns the number of bytes of direct memory used by a {@link ByteBufAllocator} or {@code -1} if unknown. 15 | /// 16 | long UsedDirectMemory { get; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Buffers/IByteBufferAllocatorMetricProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | public interface IByteBufferAllocatorMetricProvider 7 | { 8 | /// 9 | /// Returns a for a 10 | /// 11 | IByteBufferAllocatorMetric Metric { get; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Buffers/IPoolChunkListMetric.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | using System.Collections.Generic; 7 | 8 | public interface IPoolChunkListMetric : IEnumerable 9 | { 10 | /// Return the minimum usage of the chunk list before which chunks are promoted to the previous list. 11 | int MinUsage { get; } 12 | 13 | /// Return the maximum usage of the chunk list after which chunks are promoted to the next list. 14 | int MaxUsage { get; } 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Buffers/IPoolChunkMetric.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | public interface IPoolChunkMetric 7 | { 8 | /// Return the percentage of the current usage of the chunk. 9 | int Usage { get; } 10 | 11 | /// Return the size of the chunk in bytes, this is the maximum of bytes that can be served out of the chunk. 12 | int ChunkSize { get; } 13 | 14 | /// Return the number of free bytes in the chunk. 15 | int FreeBytes { get; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/DotNetty.Buffers/IPoolSubpageMetric.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers 5 | { 6 | public interface IPoolSubpageMetric 7 | { 8 | /// Return the number of maximal elements that can be allocated out of the sub-page. 9 | int MaxNumElements { get; } 10 | 11 | /// Return the number of available elements to be allocated. 12 | int NumAvailable { get; } 13 | 14 | /// Return the size (in bytes) of the elements that will be allocated. 15 | int ElementSize { get; } 16 | 17 | /// Return the size (in bytes) of this page. 18 | int PageSize { get; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Buffers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Buffers/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Buffers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | [assembly: InternalsVisibleTo("DotNetty.Microbench, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 8 | 9 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Cookies/CookieHeaderNames.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Cookies 5 | { 6 | using DotNetty.Common.Utilities; 7 | 8 | public static class CookieHeaderNames 9 | { 10 | public static readonly AsciiString Path = AsciiString.Cached("Path"); 11 | 12 | public static readonly AsciiString Expires = AsciiString.Cached("Expires"); 13 | 14 | public static readonly AsciiString MaxAge = AsciiString.Cached("Max-Age"); 15 | 16 | public static readonly AsciiString Domain = AsciiString.Cached("Domain"); 17 | 18 | public static readonly AsciiString Secure = AsciiString.Cached("Secure"); 19 | 20 | public static readonly AsciiString HttpOnly = AsciiString.Cached("HTTPOnly"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/HttpExpectationFailedEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | // A user event designed to communicate that a expectation has failed and there should be no expectation that a 7 | // body will follow. 8 | public sealed class HttpExpectationFailedEvent 9 | { 10 | public static readonly HttpExpectationFailedEvent Default = new HttpExpectationFailedEvent(); 11 | 12 | HttpExpectationFailedEvent() 13 | { 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IFullHttpMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IFullHttpMessage : IHttpMessage, ILastHttpContent 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IFullHttpRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IFullHttpRequest : IHttpRequest, IFullHttpMessage 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IFullHttpResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IFullHttpResponse : IHttpResponse, IFullHttpMessage 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IHttpContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public interface IHttpContent : IHttpObject, IByteBufferHolder 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IHttpMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IHttpMessage : IHttpObject 7 | { 8 | HttpVersion ProtocolVersion { get; } 9 | 10 | IHttpMessage SetProtocolVersion(HttpVersion version); 11 | 12 | HttpHeaders Headers { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IHttpObject.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IHttpObject : IDecoderResultProvider 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IHttpRequest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IHttpRequest : IHttpMessage 7 | { 8 | HttpMethod Method { get; } 9 | 10 | IHttpRequest SetMethod(HttpMethod method); 11 | 12 | string Uri { get; } 13 | 14 | IHttpRequest SetUri(string uri); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/IHttpResponse.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface IHttpResponse : IHttpMessage 7 | { 8 | HttpResponseStatus Status { get; } 9 | 10 | IHttpResponse SetStatus(HttpResponseStatus status); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/ILastHttpContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http 5 | { 6 | public interface ILastHttpContent : IHttpContent 7 | { 8 | HttpHeaders TrailingHeaders { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/EndOfDataDecoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | 8 | public class EndOfDataDecoderException : DecoderException 9 | { 10 | public EndOfDataDecoderException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public EndOfDataDecoderException(Exception innerException) 16 | : base(innerException) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/ErrorDataDecoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | 8 | public class ErrorDataDecoderException : DecoderException 9 | { 10 | public ErrorDataDecoderException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public ErrorDataDecoderException(Exception innerException) 16 | : base(innerException) 17 | { 18 | } 19 | 20 | public ErrorDataDecoderException(string message, Exception innerException) 21 | : base(message, innerException) 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/ErrorDataEncoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | 8 | public class ErrorDataEncoderException : Exception 9 | { 10 | public ErrorDataEncoderException(string message) 11 | : base(message) 12 | { 13 | } 14 | public ErrorDataEncoderException(Exception innerException) 15 | : base(null, innerException) 16 | { 17 | } 18 | 19 | public ErrorDataEncoderException(string message, Exception innerException) 20 | : base(message, innerException) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/FileUploadUtil.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | 8 | static class FileUploadUtil 9 | { 10 | public static int HashCode(IFileUpload upload) => upload.Name.GetHashCode(); 11 | 12 | public static bool Equals(IFileUpload upload1, IFileUpload upload2) => 13 | upload1.Name.Equals(upload2.Name, StringComparison.OrdinalIgnoreCase); 14 | 15 | public static int CompareTo(IFileUpload upload1, IFileUpload upload2) => 16 | string.Compare(upload1.Name, upload2.Name, StringComparison.OrdinalIgnoreCase); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/IAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | public interface IAttribute : IHttpData 7 | { 8 | string Value { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/IFileUpload.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | public interface IFileUpload : IHttpData 7 | { 8 | string FileName { get; set; } 9 | 10 | string ContentType { get; set; } 11 | 12 | string ContentTransferEncoding { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/IInterfaceHttpData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | using DotNetty.Common; 8 | 9 | public enum HttpDataType 10 | { 11 | Attribute, 12 | FileUpload, 13 | InternalAttribute 14 | } 15 | 16 | // Interface for all Objects that could be encoded/decoded using HttpPostRequestEncoder/Decoder 17 | public interface IInterfaceHttpData : IComparable, IReferenceCounted 18 | { 19 | string Name { get; } 20 | 21 | HttpDataType DataType { get; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/IInterfaceHttpPostRequestDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System.Collections.Generic; 7 | using DotNetty.Common.Utilities; 8 | 9 | public interface IInterfaceHttpPostRequestDecoder 10 | { 11 | bool IsMultipart { get; } 12 | 13 | int DiscardThreshold { get; set; } 14 | 15 | List GetBodyHttpDatas(); 16 | 17 | List GetBodyHttpDatas(AsciiString name); 18 | 19 | IInterfaceHttpData GetBodyHttpData(AsciiString name); 20 | 21 | IInterfaceHttpPostRequestDecoder Offer(IHttpContent content); 22 | 23 | bool HasNext { get; } 24 | 25 | IInterfaceHttpData Next(); 26 | 27 | IInterfaceHttpData CurrentPartialHttpData { get; } 28 | 29 | void Destroy(); 30 | 31 | void CleanFiles(); 32 | 33 | void RemoveHttpDataFromClean(IInterfaceHttpData data); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/MultiPartStatus.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | enum MultiPartStatus 7 | { 8 | Notstarted, 9 | Preamble, 10 | HeaderDelimiter, 11 | Disposition, 12 | Field, 13 | Fileupload, 14 | MixedPreamble, 15 | MixedDelimiter, 16 | MixedDisposition, 17 | MixedFileUpload, 18 | MixedCloseDelimiter, 19 | CloseDelimiter, 20 | PreEpilogue, 21 | Epilogue 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Multipart/NotEnoughDataDecoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Multipart 5 | { 6 | using System; 7 | 8 | public class NotEnoughDataDecoderException : DecoderException 9 | { 10 | public NotEnoughDataDecoderException(string message) : base(message) 11 | { 12 | } 13 | 14 | public NotEnoughDataDecoderException(Exception innerException) : base(innerException) 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Codecs.Http.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | [assembly: InternalsVisibleTo("DotNetty.Microbench, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 8 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/BinaryWebSocketFrame.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class BinaryWebSocketFrame : WebSocketFrame 9 | { 10 | public BinaryWebSocketFrame() 11 | : base(Unpooled.Buffer(0)) 12 | { 13 | } 14 | 15 | public BinaryWebSocketFrame(IByteBuffer binaryData) 16 | : base(binaryData) 17 | { 18 | } 19 | 20 | public BinaryWebSocketFrame(bool finalFragment, int rsv, IByteBuffer binaryData) 21 | : base(finalFragment, rsv, binaryData) 22 | { 23 | } 24 | 25 | public override IByteBufferHolder Replace(IByteBuffer content) => new BinaryWebSocketFrame(this.IsFinalFragment, this.Rsv, content); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/Compression/PerFrameDeflateDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions.Compression 5 | { 6 | class PerFrameDeflateDecoder : DeflateDecoder 7 | { 8 | public PerFrameDeflateDecoder(bool noContext) 9 | : base(noContext) 10 | { 11 | } 12 | 13 | public override bool AcceptInboundMessage(object msg) => 14 | (msg is TextWebSocketFrame || msg is BinaryWebSocketFrame || msg is ContinuationWebSocketFrame) 15 | && (((WebSocketFrame) msg).Rsv & WebSocketRsv.Rsv1) > 0; 16 | 17 | protected override int NewRsv(WebSocketFrame msg) => msg.Rsv ^ WebSocketRsv.Rsv1; 18 | 19 | protected override bool AppendFrameTail(WebSocketFrame msg) => true; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/Compression/PerFrameDeflateEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions.Compression 5 | { 6 | class PerFrameDeflateEncoder : DeflateEncoder 7 | { 8 | public PerFrameDeflateEncoder(int compressionLevel, int windowSize, bool noContext) 9 | : base(compressionLevel, windowSize, noContext) 10 | { 11 | } 12 | 13 | public override bool AcceptOutboundMessage(object msg) => 14 | (msg is TextWebSocketFrame || msg is BinaryWebSocketFrame || msg is ContinuationWebSocketFrame) 15 | && ((WebSocketFrame)msg).Content.ReadableBytes > 0 16 | && (((WebSocketFrame)msg).Rsv & WebSocketRsv.Rsv1) == 0; 17 | 18 | protected override int Rsv(WebSocketFrame msg) => msg.Rsv | WebSocketRsv.Rsv1; 19 | 20 | protected override bool RemoveFrameTail(WebSocketFrame msg) => true; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/Compression/WebSocketClientCompressionHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions.Compression 5 | { 6 | public sealed class WebSocketClientCompressionHandler : WebSocketClientExtensionHandler 7 | { 8 | public static readonly WebSocketClientCompressionHandler Instance = new WebSocketClientCompressionHandler(); 9 | 10 | public override bool IsSharable => true; 11 | 12 | WebSocketClientCompressionHandler() 13 | : base(new PerMessageDeflateClientExtensionHandshaker(), 14 | new DeflateFrameClientExtensionHandshaker(false), 15 | new DeflateFrameClientExtensionHandshaker(true)) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/Compression/WebSocketServerCompressionHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions.Compression 5 | { 6 | public class WebSocketServerCompressionHandler : WebSocketServerExtensionHandler 7 | { 8 | public WebSocketServerCompressionHandler() 9 | : base(new PerMessageDeflateServerExtensionHandshaker(), new DeflateFrameServerExtensionHandshaker()) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/IWebSocketClientExtension.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public interface IWebSocketClientExtension : IWebSocketExtension 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/IWebSocketClientExtensionHandshaker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public interface IWebSocketClientExtensionHandshaker 7 | { 8 | WebSocketExtensionData NewRequestData(); 9 | 10 | IWebSocketClientExtension HandshakeExtension(WebSocketExtensionData extensionData); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/IWebSocketExtension.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public interface IWebSocketExtension 7 | { 8 | /// 9 | /// The reserved bit value to ensure that no other extension should interfere. 10 | /// 11 | int Rsv { get; } 12 | 13 | WebSocketExtensionEncoder NewExtensionEncoder(); 14 | 15 | WebSocketExtensionDecoder NewExtensionDecoder(); 16 | } 17 | 18 | public static class WebSocketRsv 19 | { 20 | public static readonly int Rsv1 = 0x04; 21 | public static readonly int Rsv2 = 0x02; 22 | public static readonly int Rsv3 = 0x01; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/IWebSocketServerExtension.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public interface IWebSocketServerExtension : IWebSocketExtension 7 | { 8 | WebSocketExtensionData NewReponseData(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/IWebSocketServerExtensionHandshaker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public interface IWebSocketServerExtensionHandshaker 7 | { 8 | IWebSocketServerExtension HandshakeExtension(WebSocketExtensionData extensionData); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/WebSocketExtensionData.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | // ReSharper disable ConvertToAutoProperty 5 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 6 | { 7 | using System.Collections.Generic; 8 | using System.Diagnostics.Contracts; 9 | 10 | public sealed class WebSocketExtensionData 11 | { 12 | readonly string name; 13 | readonly Dictionary parameters; 14 | 15 | public WebSocketExtensionData(string name, IDictionary parameters) 16 | { 17 | Contract.Requires(name != null); 18 | Contract.Requires(parameters != null); 19 | 20 | this.name = name; 21 | this.parameters = new Dictionary(parameters); 22 | } 23 | 24 | public string Name => this.name; 25 | 26 | public Dictionary Parameters => this.parameters; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/WebSocketExtensionDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public abstract class WebSocketExtensionDecoder : MessageToMessageDecoder 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/Extensions/WebSocketExtensionEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets.Extensions 5 | { 6 | public abstract class WebSocketExtensionEncoder : MessageToMessageEncoder 7 | { 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/IWebSocketFrameDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using DotNetty.Transport.Channels; 7 | 8 | /// 9 | /// Marker interface which all WebSocketFrame decoders need to implement. This makes it 10 | /// easier to access the added encoder later in the 11 | /// 12 | public interface IWebSocketFrameDecoder : IChannelHandler 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/IWebSocketFrameEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using DotNetty.Transport.Channels; 7 | 8 | /// 9 | /// Marker interface which all WebSocketFrame encoders need to implement. This makes it 10 | /// easier to access the added encoder later in the . 11 | /// 12 | public interface IWebSocketFrameEncoder : IChannelHandler 13 | { 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/PingWebSocketFrame.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class PingWebSocketFrame : WebSocketFrame 9 | { 10 | public PingWebSocketFrame() 11 | : base(true, 0, Unpooled.Buffer(0)) 12 | { 13 | } 14 | 15 | public PingWebSocketFrame(IByteBuffer binaryData) 16 | : base(binaryData) 17 | { 18 | } 19 | 20 | public PingWebSocketFrame(bool finalFragment, int rsv, IByteBuffer binaryData) 21 | : base(finalFragment, rsv, binaryData) 22 | { 23 | } 24 | 25 | public override IByteBufferHolder Replace(IByteBuffer content) => new PingWebSocketFrame(this.IsFinalFragment, this.Rsv, content); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/PongWebSocketFrame.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class PongWebSocketFrame : WebSocketFrame 9 | { 10 | public PongWebSocketFrame() 11 | : base(Unpooled.Buffer(0)) 12 | { 13 | } 14 | 15 | public PongWebSocketFrame(IByteBuffer binaryData) 16 | : base(binaryData) 17 | { 18 | } 19 | 20 | public PongWebSocketFrame(bool finalFragment, int rsv, IByteBuffer binaryData) 21 | : base(finalFragment, rsv, binaryData) 22 | { 23 | } 24 | 25 | public override IByteBufferHolder Replace(IByteBuffer content) => new PongWebSocketFrame(this.IsFinalFragment, this.Rsv, content); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/WebSocket07FrameDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | public class WebSocket07FrameDecoder : WebSocket08FrameDecoder 7 | { 8 | public WebSocket07FrameDecoder(bool expectMaskedFrames, bool allowExtensions, int maxFramePayloadLength) 9 | : this(expectMaskedFrames, allowExtensions, maxFramePayloadLength, false) 10 | { 11 | } 12 | 13 | public WebSocket07FrameDecoder(bool expectMaskedFrames, bool allowExtensions, int maxFramePayloadLength, bool allowMaskMismatch) 14 | : base(expectMaskedFrames, allowExtensions, maxFramePayloadLength, allowMaskMismatch) 15 | { 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/WebSocket07FrameEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | public class WebSocket07FrameEncoder : WebSocket08FrameEncoder 7 | { 8 | public WebSocket07FrameEncoder(bool maskPayload) 9 | : base(maskPayload) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/WebSocket13FrameDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | public class WebSocket13FrameDecoder : WebSocket08FrameDecoder 7 | { 8 | public WebSocket13FrameDecoder(bool expectMaskedFrames, bool allowExtensions, int maxFramePayloadLength) 9 | : this(expectMaskedFrames, allowExtensions, maxFramePayloadLength, false) 10 | { 11 | } 12 | 13 | public WebSocket13FrameDecoder(bool expectMaskedFrames, bool allowExtensions,int maxFramePayloadLength, 14 | bool allowMaskMismatch) 15 | : base(expectMaskedFrames, allowExtensions, maxFramePayloadLength, allowMaskMismatch) 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/WebSocket13FrameEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | public class WebSocket13FrameEncoder : WebSocket08FrameEncoder 7 | { 8 | public WebSocket13FrameEncoder(bool maskPayload) 9 | : base(maskPayload) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Http/WebSockets/WebSocketHandshakeException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.WebSockets 5 | { 6 | using System; 7 | 8 | public class WebSocketHandshakeException : Exception 9 | { 10 | public WebSocketHandshakeException(string message, Exception innereException) 11 | : base(message, innereException) 12 | { 13 | } 14 | 15 | public WebSocketHandshakeException(string message) 16 | : base(message) 17 | { 18 | } 19 | 20 | public WebSocketHandshakeException(Exception innerException) 21 | : base(null, innerException) 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/ConnAckPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class ConnAckPacket : Packet 7 | { 8 | public override PacketType PacketType => PacketType.CONNACK; 9 | 10 | public bool SessionPresent { get; set; } 11 | 12 | public ConnectReturnCode ReturnCode { get; set; } 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/ConnectReturnCode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public enum ConnectReturnCode 7 | { 8 | Accepted = 0x00, 9 | RefusedUnacceptableProtocolVersion = 0X01, 10 | RefusedIdentifierRejected = 0x02, 11 | RefusedServerUnavailable = 0x03, 12 | RefusedBadUsernameOrPassword = 0x04, 13 | RefusedNotAuthorized = 0x05 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/DisconnectPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class DisconnectPacket : Packet 7 | { 8 | public static readonly DisconnectPacket Instance = new DisconnectPacket(); 9 | 10 | DisconnectPacket() 11 | { 12 | } 13 | 14 | public override PacketType PacketType => PacketType.DISCONNECT; 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/Packet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public abstract class Packet 7 | { 8 | public abstract PacketType PacketType { get; } 9 | 10 | public virtual bool Duplicate => false; 11 | 12 | public virtual QualityOfService QualityOfService => QualityOfService.AtMostOnce; 13 | 14 | public virtual bool RetainRequested => false; 15 | 16 | public override string ToString() 17 | { 18 | return $"{this.GetType().Name}[Type={this.PacketType}, QualityOfService={this.QualityOfService}, Duplicate={this.Duplicate}, Retain={this.RetainRequested}]"; 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PacketType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public enum PacketType 7 | { 8 | // ReSharper disable InconsistentNaming 9 | CONNECT = 1, 10 | CONNACK = 2, 11 | PUBLISH = 3, 12 | PUBACK = 4, 13 | PUBREC = 5, 14 | PUBREL = 6, 15 | PUBCOMP = 7, 16 | SUBSCRIBE = 8, 17 | SUBACK = 9, 18 | UNSUBSCRIBE = 10, 19 | UNSUBACK = 11, 20 | PINGREQ = 12, 21 | PINGRESP = 13, 22 | DISCONNECT = 14 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PacketWithId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public abstract class PacketWithId : Packet 7 | { 8 | public int PacketId { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PingReqPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PingReqPacket : Packet 7 | { 8 | public static readonly PingReqPacket Instance = new PingReqPacket(); 9 | 10 | PingReqPacket() 11 | { 12 | } 13 | 14 | public override PacketType PacketType => PacketType.PINGREQ; 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PingRespPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PingRespPacket : Packet 7 | { 8 | public static readonly PingRespPacket Instance = new PingRespPacket(); 9 | 10 | PingRespPacket() 11 | { 12 | } 13 | 14 | public override PacketType PacketType => PacketType.PINGRESP; 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PubAckPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PubAckPacket : PacketWithId 7 | { 8 | public override PacketType PacketType => PacketType.PUBACK; 9 | 10 | public static PubAckPacket InResponseTo(PublishPacket publishPacket) 11 | { 12 | return new PubAckPacket 13 | { 14 | PacketId = publishPacket.PacketId 15 | }; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PubCompPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PubCompPacket : PacketWithId 7 | { 8 | public override PacketType PacketType => PacketType.PUBCOMP; 9 | 10 | public static PubCompPacket InResponseTo(PubRelPacket publishPacket) 11 | { 12 | return new PubCompPacket 13 | { 14 | PacketId = publishPacket.PacketId 15 | }; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PubRecPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PubRecPacket : PacketWithId 7 | { 8 | public override PacketType PacketType => PacketType.PUBREC; 9 | 10 | public static PubRecPacket InResponseTo(PublishPacket publishPacket) 11 | { 12 | return new PubRecPacket 13 | { 14 | PacketId = publishPacket.PacketId 15 | }; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/PubRelPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class PubRelPacket : PacketWithId 7 | { 8 | public override PacketType PacketType => PacketType.PUBREL; 9 | 10 | public override QualityOfService QualityOfService => QualityOfService.AtLeastOnce; 11 | 12 | public static PubRelPacket InResponseTo(PubRecPacket publishPacket) 13 | { 14 | return new PubRelPacket 15 | { 16 | PacketId = publishPacket.PacketId 17 | }; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/QualityOfService.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public enum QualityOfService 7 | { 8 | AtMostOnce = 0, 9 | AtLeastOnce = 0x1, 10 | ExactlyOnce = 0x2, 11 | Reserved = 0x3, 12 | Failure = 0x80 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/SubscribePacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | using System.Collections.Generic; 7 | 8 | public sealed class SubscribePacket : PacketWithId 9 | { 10 | public SubscribePacket() 11 | { 12 | } 13 | 14 | public SubscribePacket(int packetId, params SubscriptionRequest[] requests) 15 | { 16 | this.PacketId = packetId; 17 | this.Requests = requests; 18 | } 19 | 20 | public override PacketType PacketType => PacketType.SUBSCRIBE; 21 | 22 | public override QualityOfService QualityOfService => QualityOfService.AtLeastOnce; 23 | 24 | public IReadOnlyList Requests { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/UnsubAckPacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | public sealed class UnsubAckPacket : PacketWithId 7 | { 8 | public override PacketType PacketType => PacketType.UNSUBACK; 9 | 10 | public static UnsubAckPacket InResponseTo(UnsubscribePacket unsubscribePacket) 11 | { 12 | return new UnsubAckPacket 13 | { 14 | PacketId = unsubscribePacket.PacketId 15 | }; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Packets/UnsubscribePacket.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Mqtt.Packets 5 | { 6 | using System.Collections.Generic; 7 | 8 | public sealed class UnsubscribePacket : PacketWithId 9 | { 10 | public UnsubscribePacket() 11 | { 12 | } 13 | 14 | public UnsubscribePacket(int packetId, params string[] topicFilters) 15 | { 16 | this.PacketId = packetId; 17 | this.TopicFilters = topicFilters; 18 | } 19 | 20 | public override PacketType PacketType => PacketType.UNSUBSCRIBE; 21 | 22 | public override QualityOfService QualityOfService => QualityOfService.AtLeastOnce; 23 | 24 | public IEnumerable TopicFilters { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Mqtt/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Codecs.Mqtt.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Protobuf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs.ProtocolBuffers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/IRedisMessagePool.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis 5 | { 6 | using DotNetty.Buffers; 7 | using DotNetty.Codecs.Redis.Messages; 8 | 9 | public interface IRedisMessagePool 10 | { 11 | bool TryGetSimpleString(string content, out SimpleStringRedisMessage message); 12 | 13 | bool TryGetSimpleString(IByteBuffer content, out SimpleStringRedisMessage message); 14 | 15 | bool TryGetError(string content, out ErrorRedisMessage message); 16 | 17 | bool TryGetError(IByteBuffer content, out ErrorRedisMessage message); 18 | 19 | bool TryGetInteger(IByteBuffer content, out IntegerRedisMessage message); 20 | 21 | bool TryGetInteger(long value, out IntegerRedisMessage message); 22 | 23 | bool TryGetByteBufferOfInteger(long value, out byte[] bytes); 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/AbstractStringRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using System.Diagnostics.Contracts; 7 | using System.Text; 8 | using DotNetty.Common.Utilities; 9 | 10 | public abstract class AbstractStringRedisMessage : IRedisMessage 11 | { 12 | protected AbstractStringRedisMessage(string content) 13 | { 14 | Contract.Requires(content != null); 15 | 16 | this.Content = content; 17 | } 18 | 19 | public string Content { get; } 20 | 21 | public override string ToString() => 22 | new StringBuilder(StringUtil.SimpleClassName(this)) 23 | .Append('[') 24 | .Append("content=") 25 | .Append(this.Content) 26 | .Append(']') 27 | .ToString(); 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/BulkStringHeaderRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public class BulkStringHeaderRedisMessage : IRedisMessage 7 | { 8 | public BulkStringHeaderRedisMessage(int bulkStringLength) 9 | { 10 | if (bulkStringLength <= 0) 11 | { 12 | throw new RedisCodecException($"bulkStringLength: {bulkStringLength} (expected: > 0)"); 13 | } 14 | this.BulkStringLength = bulkStringLength; 15 | } 16 | 17 | public int BulkStringLength { get; } 18 | 19 | public bool IsNull => this.BulkStringLength == RedisConstants.NullValue; 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/DefaultBulkStringRedisContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using System.Text; 7 | using DotNetty.Buffers; 8 | using DotNetty.Common.Utilities; 9 | 10 | public class DefaultBulkStringRedisContent : DefaultByteBufferHolder, IBulkStringRedisContent 11 | { 12 | public DefaultBulkStringRedisContent(IByteBuffer buffer) 13 | : base(buffer) 14 | { 15 | } 16 | 17 | public override IByteBufferHolder Replace(IByteBuffer content) => new DefaultBulkStringRedisContent(content); 18 | 19 | public override string ToString() => 20 | new StringBuilder(StringUtil.SimpleClassName(this)) 21 | .Append('[') 22 | .Append("content=") 23 | .Append(this.Content) 24 | .Append(']') 25 | .ToString(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/DefaultLastBulkStringRedisContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public sealed class DefaultLastBulkStringRedisContent : DefaultBulkStringRedisContent, ILastBulkStringRedisContent 9 | { 10 | public DefaultLastBulkStringRedisContent(IByteBuffer content) 11 | : base(content) 12 | { 13 | } 14 | 15 | public override IByteBufferHolder Replace(IByteBuffer buffer) => new DefaultLastBulkStringRedisContent(buffer); 16 | } 17 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/ErrorRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public sealed class ErrorRedisMessage : AbstractStringRedisMessage 7 | { 8 | public ErrorRedisMessage(string content) 9 | : base(content) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/IArrayRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using System.Collections.Generic; 7 | using DotNetty.Common; 8 | 9 | public interface IArrayRedisMessage : IReferenceCounted, IRedisMessage 10 | { 11 | bool IsNull { get; } 12 | 13 | IList Children { get; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/IBulkStringRedisContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public interface IBulkStringRedisContent : IRedisMessage, IByteBufferHolder 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/IFullBulkStringRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public interface IFullBulkStringRedisMessage : ILastBulkStringRedisContent 7 | { 8 | bool IsNull { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/ILastBulkStringRedisContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public interface ILastBulkStringRedisContent : IBulkStringRedisContent 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/IRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | /// 7 | /// Base interface for redis messages. 8 | /// 9 | public interface IRedisMessage 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/InlineCommandRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public sealed class InlineCommandRedisMessage : AbstractStringRedisMessage 7 | { 8 | public InlineCommandRedisMessage(string content) 9 | : base(content) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/IntegerRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | using System.Text; 7 | using DotNetty.Common.Utilities; 8 | 9 | public sealed class IntegerRedisMessage : IRedisMessage 10 | { 11 | public IntegerRedisMessage(long value) 12 | { 13 | this.Value = value; 14 | } 15 | 16 | public long Value { get; } 17 | 18 | public override string ToString() => 19 | new StringBuilder(StringUtil.SimpleClassName(this)) 20 | .Append('[') 21 | .Append("value=") 22 | .Append(this.Value) 23 | .Append(']') 24 | .ToString(); 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Messages/SimpleStringRedisMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis.Messages 5 | { 6 | public sealed class SimpleStringRedisMessage : AbstractStringRedisMessage 7 | { 8 | public SimpleStringRedisMessage(string content) 9 | : base(content) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs.Redis/RedisCodecException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Redis 5 | { 6 | using System; 7 | 8 | public sealed class RedisCodecException : CodecException 9 | { 10 | public RedisCodecException(string message) 11 | : this(message, null) 12 | { 13 | } 14 | 15 | public RedisCodecException(Exception exception) 16 | : this(null, exception) 17 | { 18 | } 19 | 20 | public RedisCodecException(string message, Exception exception) 21 | : base(message, exception) 22 | { 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Base64/Base64Decoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Base64 5 | { 6 | using System.Collections.Generic; 7 | using DotNetty.Buffers; 8 | using DotNetty.Transport.Channels; 9 | 10 | public sealed class Base64Decoder : MessageToMessageDecoder 11 | { 12 | readonly Base64Dialect dialect; 13 | 14 | public Base64Decoder() 15 | : this(Base64Dialect.STANDARD) 16 | { 17 | } 18 | 19 | public Base64Decoder(Base64Dialect dialect) 20 | { 21 | this.dialect = dialect; 22 | } 23 | 24 | protected internal override void Decode(IChannelHandlerContext context, IByteBuffer message, List output) => output.Add(Base64.Decode(message, this.dialect)); 25 | 26 | public override bool IsSharable => true; 27 | } 28 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/CodecException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | /// 9 | /// An which is thrown by a codec. 10 | /// 11 | public class CodecException : Exception 12 | { 13 | public CodecException() 14 | { 15 | } 16 | 17 | public CodecException(string message, Exception innereException) 18 | : base(message, innereException) 19 | { 20 | } 21 | 22 | public CodecException(string message) 23 | : base(message) 24 | { 25 | } 26 | 27 | public CodecException(Exception innerException) 28 | : base(null, innerException) 29 | { 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/CompressionException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | using System; 7 | 8 | public class CompressionException : EncoderException 9 | { 10 | public CompressionException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public CompressionException(string message, Exception exception) 16 | : base(message, exception) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/DecompressionException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | using System; 7 | 8 | public class DecompressionException : DecoderException 9 | { 10 | public DecompressionException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public DecompressionException(string message, Exception exception) 16 | : base(message, exception) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/IChecksum.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | interface IChecksum 7 | { 8 | void Update(byte[] buf, int index, int len); 9 | 10 | void Reset(); 11 | 12 | void Reset(long init); 13 | 14 | long GetValue(); 15 | 16 | IChecksum Copy(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/ZlibDecoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | public abstract class ZlibDecoder : ByteToMessageDecoder 7 | { 8 | public abstract bool IsClosed { get; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/ZlibEncoder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | using System.Threading.Tasks; 7 | using DotNetty.Buffers; 8 | 9 | public abstract class ZlibEncoder : MessageToByteEncoder 10 | { 11 | public abstract bool IsClosed { get; } 12 | 13 | /** 14 | * Close this {@link ZlibEncoder} and so finish the encoding. 15 | * 16 | * The returned {@link ChannelFuture} will be notified once the 17 | * operation completes. 18 | */ 19 | public abstract Task CloseAsync(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Compression/ZlibWrapper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Compression 5 | { 6 | /** 7 | * The container file formats that wrap the stream compressed by the DEFLATE 8 | * algorithm. 9 | */ 10 | public enum ZlibWrapper 11 | { 12 | /** 13 | * The ZLIB wrapper as specified in RFC 1950. 14 | */ 15 | Zlib, 16 | /** 17 | * The GZIP wrapper as specified in RFC 1952. 18 | */ 19 | Gzip, 20 | /** 21 | * Raw DEFLATE stream only (no header and no footer). 22 | */ 23 | None, 24 | /** 25 | * Try {@link #ZLIB} first and then {@link #NONE} if the first attempt fails. 26 | * Please note that you can specify this wrapper type only when decompressing. 27 | */ 28 | ZlibOrNone 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/CorruptedFrameException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | /// 9 | /// A which is thrown when the received frame data could not 10 | /// be decoded by an inbound handler. 11 | /// 12 | public class CorruptedFrameException : DecoderException 13 | { 14 | public CorruptedFrameException(string message) 15 | : base(message) 16 | { 17 | } 18 | 19 | public CorruptedFrameException(Exception cause) 20 | : base(cause) 21 | { 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/DecoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | public class DecoderException : CodecException 9 | { 10 | public DecoderException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public DecoderException(Exception cause) 16 | : base(null, cause) 17 | { 18 | } 19 | 20 | public DecoderException(string message, Exception cause) 21 | : base(message, cause) 22 | { 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/EncoderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | public class EncoderException : CodecException 9 | { 10 | public EncoderException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public EncoderException(Exception innerException) 16 | : base(null, innerException) 17 | { 18 | } 19 | 20 | public EncoderException(string message, Exception innerException) 21 | : base(message, innerException) 22 | { 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/DotNetty.Codecs/IDecoderResultProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | public interface IDecoderResultProvider 7 | { 8 | DecoderResult Result { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/INameValidator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | public interface INameValidator 7 | { 8 | void ValidateName(T name); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/MessageAggregationException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | public class MessageAggregationException : InvalidOperationException 9 | { 10 | public MessageAggregationException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public MessageAggregationException(string message, Exception cause) 16 | : base(message, cause) 17 | { 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/NullNameValidator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | public sealed class NullNameValidator : INameValidator 9 | { 10 | public void ValidateName(T name) 11 | { 12 | if (name == null) 13 | { 14 | throw new ArgumentNullException(nameof(name)); 15 | } 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/PrematureChannelClosureException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | public class PrematureChannelClosureException : CodecException 9 | { 10 | public PrematureChannelClosureException(string message) 11 | : this(message, null) 12 | { 13 | } 14 | 15 | public PrematureChannelClosureException(Exception exception) 16 | : this(null, exception) 17 | { 18 | } 19 | 20 | public PrematureChannelClosureException(string message, Exception exception) 21 | : base(message, exception) 22 | { 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Codecs/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Codecs.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/DotNetty.Codecs/TooLongFrameException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs 5 | { 6 | using System; 7 | 8 | /// 9 | /// A which is thrown when the length of the frame 10 | /// decoded is greater than the allowed maximum. 11 | /// 12 | public class TooLongFrameException : DecoderException 13 | { 14 | public TooLongFrameException(string message) 15 | : base(message) 16 | { 17 | } 18 | 19 | public TooLongFrameException(Exception cause) 20 | : base(cause) 21 | { 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/ActionScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | using System.Threading; 8 | 9 | sealed class ActionScheduledAsyncTask : ScheduledAsyncTask 10 | { 11 | readonly Action action; 12 | 13 | public ActionScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, PreciseTimeSpan deadline, CancellationToken cancellationToken) 14 | : base(executor, deadline, new TaskCompletionSource(), cancellationToken) 15 | { 16 | this.action = action; 17 | } 18 | 19 | protected override void Execute() => this.action(); 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/ActionScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | sealed class ActionScheduledTask : ScheduledTask 9 | { 10 | readonly Action action; 11 | 12 | public ActionScheduledTask(AbstractScheduledEventExecutor executor, Action action, PreciseTimeSpan deadline) 13 | : base(executor, deadline, new TaskCompletionSource()) 14 | { 15 | this.action = action; 16 | } 17 | 18 | protected override void Execute() => this.action(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/ExecutionEnvironment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | public static class ExecutionEnvironment 9 | { 10 | [ThreadStatic] 11 | static IEventExecutor currentExecutor; 12 | 13 | public static bool TryGetCurrentExecutor(out IEventExecutor executor) 14 | { 15 | executor = currentExecutor; 16 | return executor != null; 17 | } 18 | 19 | internal static void SetCurrentExecutor(IEventExecutor executor) => currentExecutor = executor; 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/ICallable`T.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | public interface ICallable 7 | { 8 | T Call(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/IRunnable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | public interface IRunnable 7 | { 8 | void Run(); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/IScheduledRunnable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | public interface IScheduledRunnable : IRunnable, IScheduledTask, IComparable 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/IScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System.Runtime.CompilerServices; 7 | using System.Threading.Tasks; 8 | 9 | public interface IScheduledTask 10 | { 11 | bool Cancel(); 12 | 13 | PreciseTimeSpan Deadline { get; } 14 | 15 | Task Completion { get; } 16 | 17 | TaskAwaiter GetAwaiter(); 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/RejectedExecutionException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | public class RejectedExecutionException : Exception 9 | { 10 | public RejectedExecutionException() 11 | { 12 | } 13 | 14 | public RejectedExecutionException(string message) 15 | : base(message) 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/RunnableScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | sealed class RunnableScheduledTask : ScheduledTask 7 | { 8 | readonly IRunnable action; 9 | 10 | public RunnableScheduledTask(AbstractScheduledEventExecutor executor, IRunnable action, PreciseTimeSpan deadline) 11 | : base(executor, deadline, new TaskCompletionSource()) 12 | { 13 | this.action = action; 14 | } 15 | 16 | protected override void Execute() => this.action.Run(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/StateActionScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | using System.Threading; 8 | 9 | sealed class StateActionScheduledAsyncTask : ScheduledAsyncTask 10 | { 11 | readonly Action action; 12 | 13 | public StateActionScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, object state, PreciseTimeSpan deadline, 14 | CancellationToken cancellationToken) 15 | : base(executor, deadline, new TaskCompletionSource(state), cancellationToken) 16 | { 17 | this.action = action; 18 | } 19 | 20 | protected override void Execute() => this.action(this.Completion.AsyncState); 21 | } 22 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/StateActionScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | sealed class StateActionScheduledTask : ScheduledTask 9 | { 10 | readonly Action action; 11 | 12 | public StateActionScheduledTask(AbstractScheduledEventExecutor executor, Action action, object state, PreciseTimeSpan deadline) 13 | : base(executor, deadline, new TaskCompletionSource(state)) 14 | { 15 | this.action = action; 16 | } 17 | 18 | protected override void Execute() => this.action(this.Completion.AsyncState); 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/StateActionWithContextScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | using System.Threading; 8 | 9 | sealed class StateActionWithContextScheduledAsyncTask : ScheduledAsyncTask 10 | { 11 | readonly Action action; 12 | readonly object context; 13 | 14 | public StateActionWithContextScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, object context, object state, 15 | PreciseTimeSpan deadline, CancellationToken cancellationToken) 16 | : base(executor, deadline, new TaskCompletionSource(state), cancellationToken) 17 | { 18 | this.action = action; 19 | this.context = context; 20 | } 21 | 22 | protected override void Execute() => this.action(this.context, this.Completion.AsyncState); 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Concurrency/StateActionWithContextScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Concurrency 5 | { 6 | using System; 7 | 8 | sealed class StateActionWithContextScheduledTask : ScheduledTask 9 | { 10 | readonly Action action; 11 | readonly object context; 12 | 13 | public StateActionWithContextScheduledTask(AbstractScheduledEventExecutor executor, Action action, object context, object state, 14 | PreciseTimeSpan deadline) 15 | : base(executor, deadline, new TaskCompletionSource(state)) 16 | { 17 | this.action = action; 18 | this.context = context; 19 | } 20 | 21 | protected override void Execute() => this.action(this.context, this.Completion.AsyncState); 22 | } 23 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/IResourceLeakHint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common 5 | { 6 | /// 7 | /// A hint object that provides human-readable message for easier resource leak tracking. 8 | /// 9 | public interface IResourceLeakHint 10 | { 11 | /// 12 | /// Returns a human-readable message that potentially enables easier resource leak tracking. 13 | /// 14 | /// 15 | string ToHintString(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/AbstractQueue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | public abstract class AbstractQueue : IQueue 7 | { 8 | public abstract bool TryEnqueue(T item); 9 | 10 | public abstract bool TryDequeue(out T item); 11 | 12 | public abstract bool TryPeek(out T item); 13 | 14 | public abstract int Count { get; } 15 | 16 | public abstract bool IsEmpty { get; } 17 | 18 | public abstract void Clear(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/CompatibleConcurrentQueue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | using System.Collections.Concurrent; 7 | 8 | public class CompatibleConcurrentQueue : ConcurrentQueue, IQueue 9 | { 10 | public bool TryEnqueue(T element) 11 | { 12 | this.Enqueue(element); 13 | return true; 14 | } 15 | 16 | void IQueue.Clear() 17 | { 18 | T item; 19 | while (this.TryDequeue(out item)) 20 | { 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/EmptyArrays.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | using DotNetty.Common.Utilities; 7 | 8 | public static class EmptyArrays 9 | { 10 | public static readonly int[] EmptyInts = { }; 11 | 12 | public static readonly byte[] EmptyBytes = { }; 13 | 14 | public static readonly char[] EmptyChars = { }; 15 | 16 | public static readonly object[] EmptyObjects = { }; 17 | 18 | public static readonly string[] EmptyStrings = { }; 19 | 20 | public static readonly AsciiString[] EmptyAsciiStrings = { }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/IAppendable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | using DotNetty.Common.Utilities; 7 | 8 | public interface IAppendable 9 | { 10 | IAppendable Append(char c); 11 | 12 | IAppendable Append(ICharSequence sequence); 13 | 14 | IAppendable Append(ICharSequence sequence, int start, int end); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/IDeque.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | public interface IDeque : IQueue 7 | { 8 | bool TryDequeueLast(out T item); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/IPlatform.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | public interface IPlatform 7 | { 8 | int GetCurrentProcessId(); 9 | 10 | byte[] GetDefaultDeviceId(); 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/IQueue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal 5 | { 6 | public interface IQueue 7 | { 8 | bool TryEnqueue(T item); 9 | 10 | bool TryDequeue(out T item); 11 | 12 | bool TryPeek(out T item); 13 | 14 | int Count { get; } 15 | 16 | bool IsEmpty { get; } 17 | 18 | void Clear(); 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/Logging/EventSourceLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal.Logging 5 | { 6 | using Microsoft.Extensions.Logging; 7 | 8 | public sealed class EventSourceLoggerProvider : ILoggerProvider 9 | { 10 | public void Dispose() 11 | { 12 | } 13 | 14 | public ILogger CreateLogger(string categoryName) => new EventSourceLogger(categoryName); 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/Logging/InternalLogLevel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Internal.Logging 5 | { 6 | /// 7 | /// The log level that can log at. 8 | /// 9 | public enum InternalLogLevel 10 | { 11 | /// 12 | /// 'TRACE' log level. 13 | /// 14 | TRACE, 15 | 16 | /// 17 | /// 'DEBUG' log level. 18 | /// 19 | DEBUG, 20 | 21 | /// 22 | /// 'INFO' log level. 23 | /// 24 | INFO, 25 | 26 | /// 27 | /// 'WARN' log level. 28 | /// 29 | WARN, 30 | 31 | /// 32 | /// 'ERROR' log level. 33 | /// 34 | ERROR 35 | } 36 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Internal/Platform.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common 5 | { 6 | using System; 7 | using DotNetty.Common.Internal; 8 | 9 | public static class Platform 10 | { 11 | public static int GetCurrentProcessId() => PlatformProvider.Platform.GetCurrentProcessId(); 12 | 13 | public static byte[] GetDefaultDeviceId() => PlatformProvider.Platform.GetDefaultDeviceId(); 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Common/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Common.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/ActionTimerTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System; 7 | 8 | public class ActionTimerTask : ITimerTask 9 | { 10 | readonly Action action; 11 | 12 | public ActionTimerTask(Action action) => this.action = action; 13 | 14 | public void Run(ITimeout timeout) => this.action(timeout); 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/BitOps.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System.Runtime.CompilerServices; 7 | 8 | public static class BitOps 9 | { 10 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 11 | public static int RightUShift(this int value, int bits) => unchecked((int)((uint)value >> bits)); 12 | 13 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 14 | public static long RightUShift(this long value, int bits) => unchecked((long)((ulong)value >> bits)); 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/ByteProcessorUtils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | static class ByteProcessorUtils 7 | { 8 | internal static readonly byte Space = (byte)' '; 9 | internal static readonly byte HTab = (byte)'\t'; 10 | internal static readonly byte CarriageReturn = (byte)'\r'; 11 | internal static readonly byte LineFeed = (byte)'\n'; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/IConstant.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | /// 7 | /// A singleton which is safe to compare via the == operator. Created and managed by 8 | /// . 9 | /// 10 | public interface IConstant 11 | { 12 | /// Returns the unique number assigned to this . 13 | int Id { get; } 14 | 15 | /// Returns the name of this . 16 | string Name { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/IHashingStrategy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System.Collections.Generic; 7 | 8 | public interface IHashingStrategy : IEqualityComparer 9 | { 10 | int HashCode(T obj); 11 | } 12 | 13 | public sealed class DefaultHashingStrategy : IHashingStrategy 14 | { 15 | public int GetHashCode(T obj) => obj.GetHashCode(); 16 | 17 | public int HashCode(T obj) => obj != null ? this.GetHashCode(obj) : 0; 18 | 19 | public bool Equals(T a, T b) => ReferenceEquals(a, b) || (!ReferenceEquals(a, null) && a.Equals(b)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/ITimerTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | /// 7 | /// A task which is executed after the delay specified with 8 | /// . 9 | /// 10 | public interface ITimerTask 11 | { 12 | /// 13 | /// Executed after the delay specified with 14 | /// . 15 | /// 16 | /// a handle which is associated with this task 17 | void Run(ITimeout timeout); 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/IllegalReferenceCountException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System; 7 | 8 | /// 9 | /// 10 | /// Exception thrown during instances where a reference count is used incorrectly 11 | /// 12 | public class IllegalReferenceCountException : InvalidOperationException 13 | { 14 | public IllegalReferenceCountException(int count) 15 | : base($"Illegal reference count of {count} for this object") 16 | { 17 | } 18 | 19 | public IllegalReferenceCountException(int refCnt, int increment) 20 | : base("refCnt: " + refCnt + ", " + (increment > 0 ? "increment: " + increment : "decrement: " + -increment)) 21 | { 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/RandomExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System; 7 | 8 | public static class RandomExtensions 9 | { 10 | public static long NextLong(this Random random) => random.Next() << 32 & unchecked((uint)random.Next()); 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/ReferenceEqualityComparer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System.Collections; 7 | using System.Collections.Generic; 8 | using System.Runtime.CompilerServices; 9 | 10 | public sealed class ReferenceEqualityComparer 11 | : IEqualityComparer, IEqualityComparer 12 | { 13 | public static readonly ReferenceEqualityComparer Default = new ReferenceEqualityComparer(); 14 | 15 | ReferenceEqualityComparer() 16 | { 17 | } 18 | 19 | public new bool Equals(object x, object y) => ReferenceEquals(x, y); 20 | 21 | public int GetHashCode(object obj) => RuntimeHelpers.GetHashCode(obj); 22 | } 23 | } -------------------------------------------------------------------------------- /src/DotNetty.Common/Utilities/ThreadExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Common.Utilities 5 | { 6 | using System; 7 | using System.Diagnostics.Contracts; 8 | using System.Threading; 9 | 10 | public static class ThreadExtensions 11 | { 12 | public static bool Join(this Thread thread, TimeSpan timeout) 13 | { 14 | long tm = (long)timeout.TotalMilliseconds; 15 | Contract.Requires(tm >= 0 && tm <= int.MaxValue); 16 | 17 | return thread.Join((int)tm); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Logging/LogLevel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Logging 5 | { 6 | using DotNetty.Common.Internal.Logging; 7 | 8 | public enum LogLevel 9 | { 10 | TRACE = InternalLogLevel.TRACE, 11 | DEBUG = InternalLogLevel.DEBUG, 12 | INFO = InternalLogLevel.INFO, 13 | WARN = InternalLogLevel.WARN, 14 | ERROR = InternalLogLevel.ERROR, 15 | } 16 | } -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Logging/LogLevelExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Logging 5 | { 6 | using DotNetty.Common.Internal.Logging; 7 | 8 | public static class LogLevelExtensions 9 | { 10 | public static InternalLogLevel ToInternalLevel(this LogLevel level) => (InternalLogLevel)level; 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Handlers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Streams/IChunkedInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Streams 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public interface IChunkedInput 9 | { 10 | bool IsEndOfInput { get; } 11 | 12 | void Close(); 13 | 14 | T ReadChunk(IByteBufferAllocator allocator); 15 | 16 | long Length { get; } 17 | 18 | long Progress { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Timeout/IdleState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Timeout 5 | { 6 | using System; 7 | 8 | /// 9 | /// An that represents the idle state of a . 10 | /// 11 | public enum IdleState 12 | { 13 | /// 14 | /// No data was received for a while. 15 | /// 16 | ReaderIdle, 17 | 18 | /// 19 | /// No data was sent for a while. 20 | /// 21 | WriterIdle, 22 | 23 | /// 24 | /// No data was either received or sent for a while. 25 | /// 26 | AllIdle 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Timeout/ReadTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Timeout 5 | { 6 | public sealed class ReadTimeoutException : TimeoutException 7 | { 8 | public readonly static ReadTimeoutException Instance = new ReadTimeoutException(); 9 | 10 | public ReadTimeoutException(string message) 11 | :base(message) 12 | { 13 | } 14 | 15 | public ReadTimeoutException() 16 | { 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Timeout/TimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers 5 | { 6 | using System.IO; 7 | 8 | public class TimeoutException : IOException 9 | { 10 | public TimeoutException(string message) 11 | :base(message) 12 | { 13 | } 14 | 15 | public TimeoutException() 16 | { 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Timeout/WriteTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Timeout 5 | { 6 | public sealed class WriteTimeoutException : TimeoutException 7 | { 8 | public readonly static WriteTimeoutException Instance = new WriteTimeoutException(); 9 | 10 | public WriteTimeoutException(string message) 11 | :base(message) 12 | { 13 | } 14 | 15 | public WriteTimeoutException() 16 | { 17 | } 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Tls/ServerTlsSniSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Tls 5 | { 6 | using System; 7 | using System.Diagnostics.Contracts; 8 | using System.Threading.Tasks; 9 | 10 | public sealed class ServerTlsSniSettings 11 | { 12 | public ServerTlsSniSettings(Func> serverTlsSettingMap, string defaultServerHostName = null) 13 | { 14 | Contract.Requires(serverTlsSettingMap != null); 15 | this.ServerTlsSettingMap = serverTlsSettingMap; 16 | this.DefaultServerHostName = defaultServerHostName; 17 | } 18 | 19 | public Func> ServerTlsSettingMap { get; } 20 | 21 | public string DefaultServerHostName { get; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/DotNetty.Handlers/Tls/TlsSettings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Tls 5 | { 6 | using System.Security.Authentication; 7 | 8 | public abstract class TlsSettings 9 | { 10 | protected TlsSettings(SslProtocols enabledProtocols, bool checkCertificateRevocation) 11 | { 12 | this.EnabledProtocols = enabledProtocols; 13 | this.CheckCertificateRevocation = checkCertificateRevocation; 14 | } 15 | 16 | public SslProtocols EnabledProtocols { get; } 17 | 18 | public bool CheckCertificateRevocation { get; } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport.Libuv/EventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Libuv 5 | { 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | using DotNetty.Transport.Channels; 9 | 10 | sealed class EventLoop : LoopExecutor, IEventLoop 11 | { 12 | public EventLoop(IEventLoopGroup parent, string threadName) 13 | : base(parent, threadName) 14 | { 15 | this.Start(); 16 | } 17 | 18 | public new IEventLoop GetNext() => (IEventLoop)base.GetNext(); 19 | 20 | public Task RegisterAsync(IChannel channel) => channel.Unsafe.RegisterAsync(this); 21 | 22 | public new IEventLoopGroup Parent => (IEventLoopGroup)base.Parent; 23 | 24 | public new IEnumerable Items => new[] { this }; 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport.Libuv/Native/RemoteConnection.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Libuv.Native 5 | { 6 | using System; 7 | 8 | sealed class RemoteConnection 9 | { 10 | public RemoteConnection(NativeHandle client, Exception error) 11 | { 12 | this.Client = client; 13 | this.Error = error; 14 | } 15 | 16 | internal NativeHandle Client { get; } 17 | 18 | internal Exception Error { get; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/DotNetty.Transport.Libuv/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Transport.Libuv/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Transport.Libuv.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/DotNetty.Transport/Bootstrapping/DefaultNameResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Bootstrapping 5 | { 6 | using System.Net; 7 | using System.Threading.Tasks; 8 | 9 | public class DefaultNameResolver : INameResolver 10 | { 11 | public bool IsResolved(EndPoint address) => !(address is DnsEndPoint); 12 | 13 | public async Task ResolveAsync(EndPoint address) 14 | { 15 | var asDns = address as DnsEndPoint; 16 | if (asDns != null) 17 | { 18 | IPHostEntry resolved = await Dns.GetHostEntryAsync(asDns.Host); 19 | return new IPEndPoint(resolved.AddressList[0], asDns.Port); 20 | } 21 | else 22 | { 23 | return address; 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Bootstrapping/INameResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Bootstrapping 5 | { 6 | using System.Net; 7 | using System.Threading.Tasks; 8 | 9 | public interface INameResolver 10 | { 11 | bool IsResolved(EndPoint address); 12 | 13 | Task ResolveAsync(EndPoint address); 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ActionChannelInitializer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | using System.Diagnostics.Contracts; 8 | using DotNetty.Common.Utilities; 9 | 10 | public sealed class ActionChannelInitializer : ChannelInitializer 11 | where T : IChannel 12 | { 13 | readonly Action initializationAction; 14 | 15 | public ActionChannelInitializer(Action initializationAction) 16 | { 17 | Contract.Requires(initializationAction != null); 18 | 19 | this.initializationAction = initializationAction; 20 | } 21 | 22 | protected override void InitChannel(T channel) => this.initializationAction(channel); 23 | 24 | public override string ToString() => nameof(ActionChannelInitializer) + "[" + StringUtil.SimpleClassName(typeof(T)) + "]"; 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/AlreadyConnectedException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | namespace DotNetty.Transport.Channels 4 | { 5 | using System; 6 | 7 | public class AlreadyConnectedException : Exception 8 | { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ChannelDuplexHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | /// 7 | /// It is a good starting point if your implementation needs to intercept operations and also 8 | /// state updates. 9 | /// 10 | public class ChannelDuplexHandler : ChannelHandlerAdapter 11 | { 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ChannelException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | public class ChannelException : Exception 9 | { 10 | public ChannelException() 11 | { 12 | } 13 | 14 | public ChannelException(string message) 15 | : base(message) 16 | { 17 | } 18 | 19 | public ChannelException(string message, Exception innerException) 20 | : base(message, innerException) 21 | { 22 | } 23 | 24 | public ChannelException(Exception innerException) 25 | : base(null, innerException) 26 | { 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ChannelPipelineException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | class ChannelPipelineException : Exception 9 | { 10 | public ChannelPipelineException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public ChannelPipelineException(string message, Exception innerException) 16 | : base(message, innerException) 17 | { 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ClosedChannelException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | using System.IO; 8 | 9 | public class ClosedChannelException : IOException 10 | { 11 | public ClosedChannelException() 12 | { 13 | } 14 | 15 | public ClosedChannelException(string message, Exception innerException) 16 | : base(message, innerException) 17 | { 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ConnectException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | public class ConnectException : Exception 9 | { 10 | public ConnectException(string message, Exception innerException) 11 | : base(message, innerException) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ConnectTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.IO; 7 | 8 | public class ConnectTimeoutException : IOException 9 | { 10 | public ConnectTimeoutException(string message) 11 | : base(message) 12 | { 13 | } 14 | 15 | public ConnectTimeoutException() 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/ConnectionPendingException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | public class ConnectionPendingException : Exception 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/DefaultChannelHandlerContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.Diagnostics.Contracts; 7 | using DotNetty.Common.Concurrency; 8 | 9 | sealed class DefaultChannelHandlerContext : AbstractChannelHandlerContext 10 | { 11 | public DefaultChannelHandlerContext( 12 | DefaultChannelPipeline pipeline, IEventExecutor executor, string name, IChannelHandler handler) 13 | : base(pipeline, executor, name, GetSkipPropagationFlags(handler)) 14 | { 15 | Contract.Requires(handler != null); 16 | 17 | this.Handler = handler; 18 | } 19 | 20 | public override IChannelHandler Handler { get; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Embedded/EmbeddedSocketAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Embedded 5 | { 6 | using System.Net; 7 | 8 | sealed class EmbeddedSocketAddress : EndPoint 9 | { 10 | public override string ToString() => "embedded"; 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Embedded/IEmbeddedChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Embedded 5 | { 6 | public interface IEmbeddedChannel : IChannel 7 | { 8 | bool WriteInbound(params object[] msgs); 9 | 10 | bool WriteOutbound(params object[] msgs); 11 | 12 | T ReadInbound(); 13 | 14 | T ReadOutbound(); 15 | 16 | bool Finish(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Groups/IChannelGroupTaskCompletionSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Groups 5 | { 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | 9 | public interface IChannelGroupTaskCompletionSource : IEnumerator 10 | { 11 | IChannelGroup Group { get; } 12 | 13 | ChannelGroupException Cause { get; } 14 | 15 | Task Find(IChannel channel); 16 | 17 | bool IsPartialSucess(); 18 | 19 | bool IsSucess(); 20 | 21 | bool IsPartialFailure(); 22 | } 23 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Groups/IChannelMatcher.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Groups 5 | { 6 | public interface IChannelMatcher 7 | { 8 | bool Matches(IChannel channel); 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IAddressedEnvelope.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.Net; 7 | using DotNetty.Common; 8 | 9 | public interface IAddressedEnvelope : IReferenceCounted 10 | { 11 | T Content { get; } 12 | 13 | EndPoint Sender { get; } 14 | 15 | EndPoint Recipient { get; } 16 | } 17 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IChannelId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | public interface IChannelId : IComparable 9 | { 10 | string AsShortText(); 11 | 12 | string AsLongText(); 13 | } 14 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IChannelUnsafe.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.Net; 7 | using System.Threading.Tasks; 8 | 9 | public interface IChannelUnsafe 10 | { 11 | IRecvByteBufAllocatorHandle RecvBufAllocHandle { get; } 12 | 13 | Task RegisterAsync(IEventLoop eventLoop); 14 | 15 | Task DeregisterAsync(); 16 | 17 | Task BindAsync(EndPoint localAddress); 18 | 19 | Task ConnectAsync(EndPoint remoteAddress, EndPoint localAddress); 20 | 21 | Task DisconnectAsync(); 22 | 23 | Task CloseAsync(); 24 | 25 | void CloseForcibly(); 26 | 27 | void BeginRead(); 28 | 29 | Task WriteAsync(object message); 30 | 31 | void Flush(); 32 | 33 | ChannelOutboundBuffer OutboundBuffer { get; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IEventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using DotNetty.Common.Concurrency; 7 | 8 | /// 9 | /// specialized to handle I/O operations of assigned s. 10 | /// 11 | public interface IEventLoop : IEventLoopGroup, IEventExecutor 12 | { 13 | /// 14 | /// Parent . 15 | /// 16 | new IEventLoopGroup Parent { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IFileRegion.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.IO; 7 | using DotNetty.Common; 8 | 9 | public interface IFileRegion : IReferenceCounted 10 | { 11 | long Position { get; } 12 | 13 | long Transferred { get; } 14 | 15 | long Count { get; } 16 | 17 | long TransferTo(Stream target, long position); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IMaxMessagesRecvByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | /// 7 | /// that limits the number of read operations that will be attempted when a read 8 | /// operation 9 | /// is attempted by the event loop. 10 | /// 11 | public interface IMaxMessagesRecvByteBufAllocator : IRecvByteBufAllocator 12 | { 13 | /// 14 | /// Gets or sets the maximum number of messages to read per read loop. 15 | /// If this value is greater than 1, an event loop might attempt to read multiple times to procure multiple messages. 16 | /// 17 | int MaxMessagesPerRead { get; set; } 18 | } 19 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IMessageSizeEstimator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | public interface IMessageSizeEstimator 7 | { 8 | /// 9 | /// Creates a new handle. The handle provides the actual operations. 10 | /// 11 | IMessageSizeEstimatorHandle NewHandle(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IMessageSizeEstimatorHandle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | public interface IMessageSizeEstimatorHandle 7 | { 8 | /// 9 | /// Calculates the size of the given message. 10 | /// 11 | /// The message for which the size should be calculated. 12 | /// The size in bytes. The returned size must be >= 0 13 | int Size(object msg); 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IRecvByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | /// 7 | /// Allocates a new receive buffer whose capacity is probably large enough to read all inbound data and small enough 8 | /// not to waste its space. 9 | /// 10 | public interface IRecvByteBufAllocator 11 | { 12 | /// 13 | /// Creates a new handle. The handle provides the actual operations and keeps the internal information which is 14 | /// required for predicting an optimal buffer capacity. 15 | /// 16 | IRecvByteBufAllocatorHandle NewHandle(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/IServerChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using DotNetty.Transport.Channels.Sockets; 7 | 8 | /// 9 | /// A that accepts an incoming connection attempt and creates its child 10 | /// s by accepting them. is a good example. 11 | /// 12 | public interface IServerChannel : IChannel 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/NotYetConnectedException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System.IO; 7 | 8 | public class NotYetConnectedException : IOException 9 | { 10 | } 11 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Pool/ChannelActiveHealthChecker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Pool 5 | { 6 | using System.Threading.Tasks; 7 | using DotNetty.Common.Utilities; 8 | 9 | /// 10 | /// implementation that checks if returns true. 11 | /// 12 | public class ChannelActiveHealthChecker : IChannelHealthChecker 13 | { 14 | public static readonly IChannelHealthChecker Instance; 15 | 16 | static ChannelActiveHealthChecker() 17 | { 18 | Instance = new ChannelActiveHealthChecker(); 19 | } 20 | 21 | ChannelActiveHealthChecker() 22 | { 23 | } 24 | 25 | public ValueTask IsHealthyAsync(IChannel channel) => new ValueTask(channel.Active); 26 | } 27 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Pool/CountingChannelPoolHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Pool 5 | { 6 | using System.Threading; 7 | 8 | public sealed class CountingChannelPoolHandler : IChannelPoolHandler 9 | { 10 | int channelCount; 11 | int acquiredCount; 12 | int releasedCount; 13 | 14 | public int ChannelCount => this.channelCount; 15 | 16 | public int AcquiredCount => this.acquiredCount; 17 | 18 | public int ReleasedCount => this.releasedCount; 19 | 20 | public void ChannelCreated(IChannel ch) => Interlocked.Increment(ref this.channelCount); 21 | 22 | public void ChannelReleased(IChannel ch) => Interlocked.Increment(ref this.releasedCount); 23 | 24 | public void ChannelAcquired(IChannel ch) => Interlocked.Increment(ref this.acquiredCount); 25 | } 26 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Pool/IChannelHealthChecker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Pool 5 | { 6 | using System.Threading.Tasks; 7 | 8 | /// 9 | /// Called before an will be returned via . 10 | /// 11 | public interface IChannelHealthChecker 12 | { 13 | /// 14 | /// Checks if the given channel is healthy (which means it can be used). This method will be called by the 15 | /// of the given 16 | /// 17 | /// The to check for healthiness. 18 | /// true if the given is healthy, otherwise false. 19 | ValueTask IsHealthyAsync(IChannel channel); 20 | } 21 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/SkipAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels 5 | { 6 | using System; 7 | 8 | [AttributeUsage(AttributeTargets.Method)] 9 | public class SkipAttribute : Attribute 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/ChannelInputShutdownEvent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | /// 7 | /// Special event which will be fired and passed to the 8 | /// methods once the input of an was shutdown and the 9 | /// property returns true. 10 | /// 11 | public sealed class ChannelInputShutdownEvent 12 | { 13 | /// 14 | /// Singleton instance to use. 15 | /// 16 | public static readonly ChannelInputShutdownEvent Instance = new ChannelInputShutdownEvent(); 17 | 18 | ChannelInputShutdownEvent() 19 | { 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/IDatagramChannelConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | using System.Net; 7 | using System.Net.NetworkInformation; 8 | 9 | public interface IDatagramChannelConfig : IChannelConfiguration 10 | { 11 | int SendBufferSize { get; set; } 12 | 13 | int ReceiveBufferSize { get; set; } 14 | 15 | int TrafficClass { get; set; } 16 | 17 | bool ReuseAddress { get; set; } 18 | 19 | bool Broadcast { get; set; } 20 | 21 | bool LoopbackModeDisabled { get; set; } 22 | 23 | short TimeToLive { get; set; } 24 | 25 | EndPoint Interface { get; set; } 26 | 27 | NetworkInterface NetworkInterface { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/IServerSocketChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | /// 7 | /// A TCP/IP which accepts incoming TCP/IP connections. 8 | /// 9 | public interface IServerSocketChannel : IServerChannel 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/IServerSocketChannelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | public interface IServerSocketChannelConfiguration : IChannelConfiguration 7 | { 8 | int Backlog { get; set; } 9 | } 10 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/ISocketChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | public interface ISocketChannel : IChannel 7 | { 8 | } 9 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Channels/Sockets/ISocketChannelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Channels.Sockets 5 | { 6 | public interface ISocketChannelConfiguration : IChannelConfiguration 7 | { 8 | bool AllowHalfClosure { get; set; } 9 | 10 | int ReceiveBufferSize { get; set; } 11 | 12 | int SendBufferSize { get; set; } 13 | 14 | int Linger { get; set; } 15 | 16 | bool KeepAlive { get; set; } 17 | 18 | bool ReuseAddress { get; set; } 19 | 20 | bool TcpNoDelay { get; set; } 21 | } 22 | } -------------------------------------------------------------------------------- /src/DotNetty.Transport/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /src/DotNetty.Transport/Properties/Friends.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Runtime.CompilerServices; 5 | 6 | [assembly: InternalsVisibleTo("DotNetty.Transport.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d9782d5a0b850f230f71e06de2e101d8441d83e15eef715837eee38fdbf5cb369b41ec36e6e7668c18cbb09e5419c179360461e740c1cce6ffbdcf81f245e1e705482797fe42aff2d31ecd72ea87362ded3c14066746fbab4a8e1896f8b982323c84e2c1b08407c0de18b7feef1535fb972a3b26181f5a304ebd181795a46d8f")] 7 | -------------------------------------------------------------------------------- /src/shared/SharedAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by Cake. 4 | // 5 | //------------------------------------------------------------------------------ 6 | using System.Reflection; 7 | 8 | [assembly: AssemblyCompany("Microsoft")] 9 | [assembly: AssemblyProduct("DotNetty")] 10 | [assembly: AssemblyVersion("0.7.6")] 11 | [assembly: AssemblyFileVersion("0.7.6")] 12 | [assembly: AssemblyCopyright("(c) Microsoft 2015 - 2021")] 13 | 14 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/AdvancedLeakAwareByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using System; 7 | using DotNetty.Common; 8 | 9 | public class AdvancedLeakAwareByteBufferTests : SimpleLeakAwareByteBufferTests 10 | { 11 | protected override Type ByteBufferType => typeof(AdvancedLeakAwareByteBuffer); 12 | 13 | protected override IByteBuffer Wrap(IByteBuffer buffer, IResourceLeakTracker tracker) => new AdvancedLeakAwareByteBuffer(buffer, tracker); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/AdvancedLeakAwareCompositeByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using System; 7 | using DotNetty.Common; 8 | 9 | public class AdvancedLeakAwareCompositeByteBufferTests : SimpleLeakAwareCompositeByteBufferTests 10 | { 11 | protected override IByteBuffer Wrap(CompositeByteBuffer buffer, IResourceLeakTracker tracker) => new AdvancedLeakAwareCompositeByteBuffer(buffer, tracker); 12 | 13 | protected override Type ByteBufferType => typeof(AdvancedLeakAwareByteBuffer); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/CompositeByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | namespace DotNetty.Buffers.Tests 4 | { 5 | public class CompositeByteBufferTests : AbstractCompositeByteBufferTests 6 | { 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/HeapByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using Xunit; 7 | 8 | public class HeapByteBufferTests : AbstractByteBufferTests 9 | { 10 | protected override IByteBuffer NewBuffer(int length, int maxCapacity) 11 | { 12 | IByteBuffer buffer = new UnpooledHeapByteBuffer(UnpooledByteBufferAllocator.Default, length, maxCapacity); 13 | Assert.Equal(0, buffer.WriterIndex); 14 | return buffer; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/NoopResourceLeakTracker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using System.Threading; 7 | using DotNetty.Common; 8 | 9 | sealed class NoopResourceLeakTracker : IResourceLeakTracker 10 | { 11 | long value; 12 | 13 | public bool Closed => this.value == 1; 14 | 15 | public void Record() 16 | { 17 | // NOOP 18 | } 19 | 20 | public void Record(object hint) 21 | { 22 | // NOOP 23 | } 24 | 25 | public bool Close(object trackedObject) 26 | { 27 | return Interlocked.CompareExchange(ref this.value, 1, 0) == 0; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/PooledDirectByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | public sealed class PooledDirectByteBufferTests : AbstractPooledByteBufferTests 7 | { 8 | protected override IByteBuffer Alloc(int length, int maxCapacity) => PooledByteBufferAllocator.Default.DirectBuffer(length, maxCapacity); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/PooledHeapByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | public sealed class PooledHeapByteBufferTests : AbstractPooledByteBufferTests 7 | { 8 | protected override IByteBuffer Alloc(int length, int maxCapacity) => PooledByteBufferAllocator.Default.HeapBuffer(length, maxCapacity); 9 | } 10 | } -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/RetainedSlicedByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using Xunit; 7 | 8 | public class RetainedSlicedByteBufferTests : SlicedByteBufferTest 9 | { 10 | protected override IByteBuffer NewSlice(IByteBuffer buffer, int offset, int length) 11 | { 12 | IByteBuffer slice = buffer.RetainedSlice(offset, length); 13 | buffer.Release(); 14 | Assert.Equal(buffer.ReferenceCount, slice.ReferenceCount); 15 | return slice; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/UnpooledByteBufferAllocatorTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | public class UnpooledByteBufferAllocatorTests : AbstractByteBufferAllocatorTests 7 | { 8 | protected override IByteBufferAllocator NewAllocator(bool preferDirect) => new UnpooledByteBufferAllocator(preferDirect); 9 | 10 | protected override IByteBufferAllocator NewUnpooledAllocator() => new UnpooledByteBufferAllocator(false); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/UnreleaseableByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using Xunit; 7 | 8 | public class UnreleaseableByteBufferTests 9 | { 10 | [Fact] 11 | public void CantRelease() 12 | { 13 | IByteBuffer buffer = Unpooled.UnreleasableBuffer(Unpooled.Buffer(1)); 14 | 15 | Assert.Equal(1, buffer.ReferenceCount); 16 | Assert.False(buffer.Release()); 17 | Assert.Equal(1, buffer.ReferenceCount); 18 | Assert.False(buffer.Release()); 19 | Assert.Equal(1, buffer.ReferenceCount); 20 | 21 | buffer.Retain(5); 22 | Assert.Equal(1, buffer.ReferenceCount); 23 | 24 | buffer.Retain(); 25 | Assert.Equal(1, buffer.ReferenceCount); 26 | 27 | Assert.True(buffer.Unwrap().Release()); 28 | Assert.Equal(0, buffer.ReferenceCount); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/UnsafeDirectByteBufferTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | using Xunit; 7 | 8 | public class UnsafeDirectByteBufferTest : AbstractByteBufferTests 9 | { 10 | protected override IByteBuffer NewBuffer(int length, int maxCapacity) 11 | { 12 | IByteBuffer buffer = this.NewDirectBuffer(length, maxCapacity); 13 | Assert.Equal(0, buffer.WriterIndex); 14 | return buffer; 15 | } 16 | 17 | protected IByteBuffer NewDirectBuffer(int length, int maxCapacity) => 18 | new UnpooledUnsafeDirectByteBuffer(UnpooledByteBufferAllocator.Default, length, maxCapacity); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /test/DotNetty.Buffers.Tests/WrappedCompositeByteBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Buffers.Tests 5 | { 6 | public class WrappedCompositeByteBufferTests : CompositeByteBufferTests 7 | { 8 | protected sealed override IByteBuffer NewBuffer(int length, int maxCapacity) => this.Wrap((CompositeByteBuffer)base.NewBuffer(length, maxCapacity)); 9 | 10 | protected virtual IByteBuffer Wrap(CompositeByteBuffer buffer) => new WrappedCompositeByteBuffer(buffer); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/Multipart/DiskFileUploadTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.Multipart 5 | { 6 | using DotNetty.Codecs.Http.Multipart; 7 | using Xunit; 8 | 9 | public sealed class DiskFileUploadTest 10 | { 11 | [Fact] 12 | public void DiskFileUploadEquals() 13 | { 14 | var f2 = new DiskFileUpload("d1", "d1", "application/json", null, null, 100); 15 | Assert.Equal(f2, f2); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/Multipart/MemoryFileUploadTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.Multipart 5 | { 6 | using DotNetty.Codecs.Http.Multipart; 7 | using Xunit; 8 | 9 | public sealed class MemoryFileUploadTest 10 | { 11 | [Fact] 12 | public void MemoryFileUploadEquals() 13 | { 14 | var f1 = new MemoryFileUpload("m1", "m1", "application/json", null, null, 100); 15 | Assert.Equal(f1, f1); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/Multipart/file-01.txt: -------------------------------------------------------------------------------- 1 | File 01 2 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/Multipart/file-02.txt: -------------------------------------------------------------------------------- 1 | File 02 2 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/Extensions/WebSocketExtensionUtilTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets.Extensions 5 | { 6 | using DotNetty.Codecs.Http.WebSockets.Extensions; 7 | using Xunit; 8 | 9 | public sealed class WebSocketExtensionUtilTest 10 | { 11 | [Fact] 12 | public void IsWebsocketUpgrade() 13 | { 14 | HttpHeaders headers = new DefaultHttpHeaders(); 15 | Assert.False(WebSocketExtensionUtil.IsWebsocketUpgrade(headers)); 16 | 17 | headers.Add(HttpHeaderNames.Upgrade, HttpHeaderValues.Websocket); 18 | Assert.False(WebSocketExtensionUtil.IsWebsocketUpgrade(headers)); 19 | 20 | headers.Add(HttpHeaderNames.Connection, "Keep-Alive, Upgrade"); 21 | Assert.True(WebSocketExtensionUtil.IsWebsocketUpgrade(headers)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/WebSocket08FrameDecoderTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets 5 | { 6 | using DotNetty.Codecs.Http.WebSockets; 7 | using DotNetty.Transport.Channels; 8 | using Moq; 9 | using Xunit; 10 | 11 | public sealed class WebSocket08FrameDecoderTest 12 | { 13 | [Fact] 14 | public void ChannelInactive() 15 | { 16 | var decoder = new WebSocket08FrameDecoder(true, true, 65535, false); 17 | var ctx = new Mock(MockBehavior.Strict); 18 | ctx.Setup(x => x.FireChannelInactive()).Returns(ctx.Object); 19 | 20 | decoder.ChannelInactive(ctx.Object); 21 | ctx.Verify(x => x.FireChannelInactive(), Times.Once); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/WebSocketClientHandshaker00Test.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets 5 | { 6 | using System; 7 | using DotNetty.Codecs.Http.WebSockets; 8 | using DotNetty.Common.Utilities; 9 | 10 | public class WebSocketClientHandshaker00Test : WebSocketClientHandshakerTest 11 | { 12 | protected override WebSocketClientHandshaker NewHandshaker(Uri uri) => 13 | new WebSocketClientHandshaker00(uri, WebSocketVersion.V00, null, null, 1024); 14 | 15 | protected override AsciiString GetOriginHeaderName() => HttpHeaderNames.Origin; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/WebSocketClientHandshaker07Test.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets 5 | { 6 | using System; 7 | using DotNetty.Codecs.Http.WebSockets; 8 | using DotNetty.Common.Utilities; 9 | 10 | public class WebSocketClientHandshaker07Test : WebSocketClientHandshakerTest 11 | { 12 | protected override WebSocketClientHandshaker NewHandshaker(Uri uri) => new WebSocketClientHandshaker07(uri, WebSocketVersion.V07, null, false, null, 1024); 13 | 14 | protected override AsciiString GetOriginHeaderName() => HttpHeaderNames.SecWebsocketOrigin; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/WebSocketClientHandshaker08Test.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets 5 | { 6 | using System; 7 | using DotNetty.Codecs.Http.WebSockets; 8 | 9 | public class WebSocketClientHandshaker08Test : WebSocketClientHandshaker07Test 10 | { 11 | protected override WebSocketClientHandshaker NewHandshaker(Uri uri) => new WebSocketClientHandshaker08(uri, WebSocketVersion.V08, null, false, null, 1024); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Http.Tests/WebSockets/WebSocketClientHandshaker13Test.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Http.Tests.WebSockets 5 | { 6 | using System; 7 | using DotNetty.Codecs.Http.WebSockets; 8 | 9 | public class WebSocketClientHandshaker13Test : WebSocketClientHandshaker07Test 10 | { 11 | protected override WebSocketClientHandshaker NewHandshaker(Uri uri) => new WebSocketClientHandshaker13(uri, WebSocketVersion.V13, null, false, null, 1024); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Protobuf.Tests/Addressbook.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | package Google.Protobuf.Examples.AddressBook; 3 | 4 | // [START messages] 5 | message Person { 6 | string name = 1; 7 | int32 id = 2; // Unique ID number for this person. 8 | string email = 3; 9 | 10 | enum PhoneType { 11 | MOBILE = 0; 12 | HOME = 1; 13 | WORK = 2; 14 | } 15 | 16 | message PhoneNumber { 17 | string number = 1; 18 | PhoneType type = 2; 19 | } 20 | 21 | repeated PhoneNumber phones = 4; 22 | } 23 | 24 | // Our address book file is just one of these. 25 | message AddressBook { 26 | repeated Person people = 1; 27 | } -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Protobuf.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("DotNetty.Codecs.Protobuf.Tests")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("57ab7999-1705-4f12-a05d-89fec4eaa305")] 20 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.ProtocolBuffers.Tests/AddressBook.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package Google.Protobuf.Examples.AddressBook; 4 | 5 | message Person { 6 | required string name = 1; 7 | required int32 id = 2; // Unique ID number for this person. 8 | optional string email = 3; 9 | enum PhoneType { 10 | MOBILE = 0; 11 | HOME = 1; 12 | WORK = 2; 13 | } 14 | message PhoneNumber { 15 | required string number = 1; 16 | optional PhoneType type = 2 [default = HOME]; 17 | } 18 | repeated PhoneNumber phone = 4; 19 | } 20 | // Our address book file is just one of these. 21 | message AddressBook { 22 | repeated Person person = 1; 23 | } -------------------------------------------------------------------------------- /test/DotNetty.Codecs.ProtocolBuffers.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("")] 10 | [assembly: AssemblyProduct("DotNetty.Codecs.ProtocolBuffers.Tests")] 11 | [assembly: AssemblyTrademark("")] 12 | 13 | // Setting ComVisible to false makes the types in this assembly not visible 14 | // to COM components. If you need to access a type in this assembly from 15 | // COM, set the ComVisible attribute to true on that type. 16 | [assembly: ComVisible(false)] 17 | 18 | // The following GUID is for the ID of the typelib if this project is exposed to COM 19 | [assembly: Guid("e33a7419-e4e8-4243-a2e5-7376ba32d608")] 20 | -------------------------------------------------------------------------------- /test/DotNetty.Codecs.Tests/Protobuf/TestUtil.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Codecs.Tests.Protobuf 5 | { 6 | using DotNetty.Buffers; 7 | 8 | static class TestUtil 9 | { 10 | internal static byte[] GetReadableBytes(IByteBuffer byteBuffer) 11 | { 12 | var data = new byte[byteBuffer.ReadableBytes]; 13 | byteBuffer.ReadBytes(data); 14 | 15 | return data; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/DotNetty.Common.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | using System.Reflection; 5 | using System.Resources; 6 | 7 | [assembly: NeutralResourcesLanguage("en-US")] 8 | [assembly: AssemblyMetadata("Serviceable", "True")] -------------------------------------------------------------------------------- /test/DotNetty.Common.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/DotNetty.Handlers.Tests/AsIsWriteStrategy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Tests 5 | { 6 | using System; 7 | using System.Threading.Tasks; 8 | using DotNetty.Buffers; 9 | using DotNetty.Common.Utilities; 10 | using DotNetty.Transport.Channels.Embedded; 11 | 12 | class AsIsWriteStrategy : IWriteStrategy 13 | { 14 | public Task WriteToChannelAsync(IEmbeddedChannel channel, ArraySegment input) 15 | { 16 | channel.WriteInbound(Unpooled.WrappedBuffer(input.Array, input.Offset, input.Count)); 17 | return TaskEx.Completed; 18 | } 19 | 20 | public override string ToString() => "as-is"; 21 | } 22 | } -------------------------------------------------------------------------------- /test/DotNetty.Handlers.Tests/IWriteStrategy.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Handlers.Tests 5 | { 6 | using System; 7 | using System.Threading.Tasks; 8 | using DotNetty.Transport.Channels.Embedded; 9 | 10 | public interface IWriteStrategy 11 | { 12 | Task WriteToChannelAsync(IEmbeddedChannel channel, ArraySegment input); 13 | } 14 | } -------------------------------------------------------------------------------- /test/DotNetty.Microbench/Allocators/PooledByteBufferAllocatorBenchmark.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Microbench.Allocators 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class PooledByteBufferAllocatorBenchmark : AbstractByteBufferAllocatorBenchmark 9 | { 10 | public PooledByteBufferAllocatorBenchmark() 11 | : base(new PooledByteBufferAllocator(true, 4, 4, 8192, 11, 0, 0, 0)) // Disable thread-local cache 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Microbench/Allocators/PooledHeapByteBufferAllocatorBenchmark.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Microbench.Allocators 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class PooledHeapByteBufferAllocatorBenchmark : AbstractByteBufferAllocatorBenchmark 9 | { 10 | public PooledHeapByteBufferAllocatorBenchmark() 11 | : base( new PooledByteBufferAllocator(true, 4, 4, 8192, 11, 0, 0, 0)) // Disable thread-local cache 12 | { 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Microbench/Allocators/UnpooledByteBufferAllocatorBenchmark.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Microbench.Allocators 5 | { 6 | using DotNetty.Buffers; 7 | 8 | public class UnpooledHeapByteBufferAllocatorBenchmark : AbstractByteBufferAllocatorBenchmark 9 | { 10 | public UnpooledHeapByteBufferAllocatorBenchmark() : base(new UnpooledByteBufferAllocator(true)) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/DotNetty.Microbench/Codecs/DateFormatterBenchmark.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Microbench.Codecs 5 | { 6 | using System; 7 | using BenchmarkDotNet.Attributes; 8 | using BenchmarkDotNet.Jobs; 9 | using DotNetty.Codecs; 10 | 11 | [SimpleJob(RuntimeMoniker.NetCoreApp31)] 12 | [BenchmarkCategory("Codecs")] 13 | public class DateFormatterBenchmark 14 | { 15 | const string DateString = "Sun, 27 Nov 2016 19:18:46 GMT"; 16 | readonly DateTime date = new DateTime(784111777000L); 17 | 18 | [Benchmark] 19 | public DateTime? ParseHttpHeaderDateFormatter() => DateFormatter.ParseHttpDate(DateString); 20 | 21 | [Benchmark] 22 | public string FormatHttpHeaderDateFormatter() => DateFormatter.Format(this.date); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/ChannelExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.Common 5 | { 6 | using System.Collections.Generic; 7 | using System.Threading.Tasks; 8 | using DotNetty.Transport.Channels; 9 | 10 | public static class ChannelExtensions 11 | { 12 | public static Task WriteAndFlushManyAsync(this IChannel channel, params object[] messages) 13 | { 14 | var list = new List(); 15 | foreach (object m in messages) 16 | { 17 | list.Add(channel.WriteAsync(m)); 18 | } 19 | IEnumerable tasks = list.ToArray(); 20 | channel.Flush(); 21 | return Task.WhenAll(tasks); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/Disposable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.Common 5 | { 6 | using System; 7 | using System.Threading; 8 | 9 | public sealed class Disposable : IDisposable 10 | { 11 | Action disposeAction; 12 | 13 | public Disposable(Action disposeAction) 14 | { 15 | this.disposeAction = disposeAction; 16 | } 17 | 18 | public void Dispose() 19 | { 20 | Action action = Interlocked.Exchange(ref this.disposeAction, null); 21 | action?.Invoke(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/EnumerableExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.Common 5 | { 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | public static class EnumerableExtensions 10 | { 11 | public static IEnumerable> Split(this IEnumerable src, Func splitFunc) 12 | { 13 | var group = new List(); 14 | foreach (T elem in src) 15 | { 16 | if (splitFunc(elem)) 17 | { 18 | yield return group; 19 | group = new List(); 20 | } 21 | else 22 | { 23 | group.Add(elem); 24 | } 25 | } 26 | yield return group; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/TestBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.Common 5 | { 6 | using DotNetty.Common.Internal.Logging; 7 | using Xunit.Abstractions; 8 | 9 | public abstract class TestBase 10 | { 11 | protected readonly ITestOutputHelper Output; 12 | 13 | protected TestBase(ITestOutputHelper output) 14 | { 15 | this.Output = output; 16 | InternalLoggerFactory.DefaultFactory.AddProvider(new XUnitOutputLoggerProvider(output)); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/XUnitOutputLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | namespace DotNetty.Tests.Common 2 | { 3 | using Microsoft.Extensions.Logging; 4 | using Xunit.Abstractions; 5 | 6 | sealed class XUnitOutputLoggerProvider : ILoggerProvider 7 | { 8 | readonly ITestOutputHelper output; 9 | 10 | public XUnitOutputLoggerProvider(ITestOutputHelper output) 11 | { 12 | this.output = output; 13 | } 14 | 15 | public void Dispose() 16 | { 17 | } 18 | 19 | public ILogger CreateLogger(string categoryName) => new XUnitOutputLogger(categoryName, this.output); 20 | } 21 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.Common/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/DotNetty.Tests.End2End/EchoChannelHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.End2End 5 | { 6 | using System; 7 | using DotNetty.Transport.Channels; 8 | 9 | class EchoChannelHandler : ChannelHandlerAdapter 10 | { 11 | public override void ChannelRead(IChannelHandlerContext context, object message) => context.Channel.WriteAsync(message); 12 | 13 | public override void ChannelReadComplete(IChannelHandlerContext context) => context.Channel.Flush(); 14 | 15 | public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.End2End/ExceptionCatchHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Tests.End2End 5 | { 6 | using System; 7 | using System.Diagnostics.Contracts; 8 | using DotNetty.Transport.Channels; 9 | 10 | class ExceptionCatchHandler : ChannelHandlerAdapter 11 | { 12 | readonly Action exceptionCaughtAction; 13 | 14 | public ExceptionCatchHandler(Action exceptionCaughtAction) 15 | { 16 | Contract.Requires(exceptionCaughtAction != null); 17 | this.exceptionCaughtAction = exceptionCaughtAction; 18 | } 19 | 20 | public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) => this.exceptionCaughtAction(exception); 21 | } 22 | } -------------------------------------------------------------------------------- /test/DotNetty.Tests.End2End/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Libuv.Tests/TestUtil.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Libuv.Tests 5 | { 6 | using System; 7 | using System.Net; 8 | 9 | static class TestUtil 10 | { 11 | // Unit test collection name, this is to avoid paralleled unit 12 | // testing starting bind/listen on loopback at the same time 13 | // on multiple threads (xunit default to the number of CPU cores) 14 | // causing channel initial operations to timeout. 15 | internal const string LibuvTransport = "Libuv Transport Tests"; 16 | 17 | internal static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(10); 18 | 19 | internal static readonly IPEndPoint LoopbackAnyPort = new IPEndPoint(IPAddress.IPv6Loopback, 0); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Transport/LibuvPingPongPerfSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Transport 5 | { 6 | using DotNetty.Transport.Channels; 7 | using DotNetty.Transport.Libuv; 8 | 9 | public sealed class LibuvPingPongPerfSpecs : AbstractPingPongPerfSpecs 10 | { 11 | protected override IEventLoopGroup NewServerGroup() => new DispatcherEventLoopGroup(); 12 | 13 | protected override IEventLoopGroup NewWorkerGroup(IEventLoopGroup serverGroup) => new WorkerEventLoopGroup((DispatcherEventLoopGroup)serverGroup, 1); 14 | 15 | protected override IEventLoopGroup NewClientGroup() => new EventLoopGroup(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Transport/LibuvPumpPerfSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Transport 5 | { 6 | using DotNetty.Transport.Channels; 7 | using DotNetty.Transport.Libuv; 8 | 9 | public sealed class LibuvPumpPerfSpecs : AbstractPumpPerfSpecs 10 | { 11 | protected override IEventLoopGroup NewServerGroup() => new DispatcherEventLoopGroup(); 12 | 13 | protected override IEventLoopGroup NewWorkerGroup(IEventLoopGroup serverGroup) => new WorkerEventLoopGroup((DispatcherEventLoopGroup)serverGroup, 1); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Transport/SocketPingPongPerfSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Transport 5 | { 6 | using DotNetty.Transport.Channels; 7 | using DotNetty.Transport.Channels.Sockets; 8 | 9 | public sealed class SocketPingPongPerfSpecs : AbstractPingPongPerfSpecs 10 | { 11 | protected override IEventLoopGroup NewServerGroup() => new MultithreadEventLoopGroup(1); 12 | 13 | protected override IEventLoopGroup NewWorkerGroup(IEventLoopGroup serverGroup) => new MultithreadEventLoopGroup(1); 14 | 15 | protected override IEventLoopGroup NewClientGroup() => new MultithreadEventLoopGroup(1); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Transport/SocketPumpPerfSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Transport 5 | { 6 | using DotNetty.Transport.Channels; 7 | using DotNetty.Transport.Channels.Sockets; 8 | 9 | public sealed class SocketPumpPerfSpecs : AbstractPumpPerfSpecs 10 | { 11 | protected override IEventLoopGroup NewServerGroup() => new MultithreadEventLoopGroup(1); 12 | 13 | protected override IEventLoopGroup NewWorkerGroup(IEventLoopGroup serverGroup) => new MultithreadEventLoopGroup(1); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/CounterHandlerInbound.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | using DotNetty.Transport.Channels; 7 | using NBench; 8 | 9 | class CounterHandlerInbound : ChannelHandlerAdapter 10 | { 11 | readonly Counter throughput; 12 | 13 | public CounterHandlerInbound(Counter throughput) 14 | { 15 | this.throughput = throughput; 16 | } 17 | 18 | public override void ChannelRead(IChannelHandlerContext context, object message) 19 | { 20 | this.throughput.Increment(); 21 | context.FireChannelRead(message); 22 | } 23 | 24 | public override bool IsSharable => true; 25 | } 26 | } -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/CounterHandlerOutbound.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | using System.Threading.Tasks; 7 | using DotNetty.Transport.Channels; 8 | using NBench; 9 | 10 | class CounterHandlerOutbound : ChannelHandlerAdapter 11 | { 12 | readonly Counter throughput; 13 | 14 | public CounterHandlerOutbound(Counter throughput) 15 | { 16 | this.throughput = throughput; 17 | } 18 | 19 | public override Task WriteAsync(IChannelHandlerContext context, object message) 20 | { 21 | this.throughput.Increment(); 22 | return context.WriteAsync(message); 23 | } 24 | 25 | public override bool IsSharable => true; 26 | } 27 | } -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/IReadFinishedSignal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | public interface IReadFinishedSignal 7 | { 8 | bool Finished { get; } 9 | 10 | void Signal(); 11 | } 12 | } -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/ManualResetEventSlimReadFinishedSignal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | using System.Threading; 7 | 8 | public class ManualResetEventSlimReadFinishedSignal : IReadFinishedSignal 9 | { 10 | readonly ManualResetEventSlim manualResetEventSlim; 11 | 12 | public ManualResetEventSlimReadFinishedSignal(ManualResetEventSlim manualResetEventSlim) 13 | { 14 | this.manualResetEventSlim = manualResetEventSlim; 15 | } 16 | 17 | public void Signal() => this.manualResetEventSlim.Set(); 18 | 19 | public bool Finished => this.manualResetEventSlim.IsSet; 20 | } 21 | } -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/SimpleReadFinishedSignal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | public class SimpleReadFinishedSignal : IReadFinishedSignal 7 | { 8 | public void Signal() 9 | { 10 | this.Finished = true; 11 | } 12 | 13 | public bool Finished { get; private set; } 14 | } 15 | } -------------------------------------------------------------------------------- /test/DotNetty.Transport.Tests.Performance/Utilities/TaskCompletionSourceFinishedSignal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft. All rights reserved. 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | 4 | namespace DotNetty.Transport.Tests.Performance.Utilities 5 | { 6 | using DotNetty.Common.Concurrency; 7 | 8 | public class TaskCompletionSourceFinishedSignal : IReadFinishedSignal 9 | { 10 | readonly TaskCompletionSource tcs; 11 | 12 | public TaskCompletionSourceFinishedSignal(TaskCompletionSource tcs) 13 | { 14 | this.tcs = tcs; 15 | } 16 | 17 | public void Signal() => this.tcs.TryComplete(); 18 | 19 | public bool Finished => this.tcs.Task.IsCompleted; 20 | } 21 | } --------------------------------------------------------------------------------