当前位置: 首页>>代码示例>>C#>>正文


C# IByteBuffer.IsReadable方法代码示例

本文整理汇总了C#中IByteBuffer.IsReadable方法的典型用法代码示例。如果您正苦于以下问题:C# IByteBuffer.IsReadable方法的具体用法?C# IByteBuffer.IsReadable怎么用?C# IByteBuffer.IsReadable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IByteBuffer的用法示例。


在下文中一共展示了IByteBuffer.IsReadable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleReadException

 void HandleReadException(IChannelPipeline pipeline, IByteBuffer byteBuf, Exception cause, bool close)
 {
     if (byteBuf != null)
     {
         if (byteBuf.IsReadable())
         {
             this.Channel.ReadPending = false;
             pipeline.FireChannelRead(byteBuf);
         }
         else
         {
             byteBuf.Release();
         }
     }
     pipeline.FireChannelReadComplete();
     pipeline.FireExceptionCaught(cause);
     if (close || cause is SocketException)
     {
         this.CloseOnRead();
     }
 }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:21,代码来源:AbstractSocketByteChannel.cs

示例2: CompareTo

 public int CompareTo(IByteBuffer buffer) => buffer.IsReadable() ? -1 : 0;
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:1,代码来源:EmptyByteBuffer.cs

示例3: CallDecode

        protected virtual void CallDecode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
        {
            try
            {
                while (input.IsReadable())
                {
                    int initialOutputCount = output.Count;
                    int oldInputLength = input.ReadableBytes;
                    this.Decode(context, input, output);

                    // Check if this handler was removed before continuing the loop.
                    // If it was removed, it is not safe to continue to operate on the buffer.
                    //
                    // See https://github.com/netty/netty/issues/1664
                    if (context.Removed)
                    {
                        break;
                    }

                    if (initialOutputCount == output.Count)
                    {
                        // no outgoing messages have been produced

                        if (oldInputLength == input.ReadableBytes)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (oldInputLength == input.ReadableBytes)
                    {
                        throw new DecoderException(string.Format("{0}.Decode() did not read anything but decoded a message.", this.GetType().Name));
                    }

                    if (this.SingleDecode)
                    {
                        break;
                    }
                }
            }
            catch (DecoderException)
            {
                throw;
            }
            catch (Exception cause)
            {
                throw new DecoderException(cause);
            }
        }
开发者ID:l1183479157,项目名称:DotNetty,代码行数:53,代码来源:ByteToMessageDecoder.cs

示例4: CreateMessage

 public IMessage CreateMessage(string address, IByteBuffer payload) => new IotHubClientMessage(address, new Message(payload.IsReadable() ? new ReadOnlyByteBufferStream(payload, true) : null));
开发者ID:mtuchkov,项目名称:azure-iot-protocol-gateway,代码行数:1,代码来源:IotHubClient.cs

示例5: Equals

 public bool Equals(IByteBuffer buffer) => buffer != null && !buffer.IsReadable();
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:1,代码来源:EmptyByteBuffer.cs

示例6: CreateMessage

 public IMessage CreateMessage(string address, IByteBuffer payload)
 {
     var message = new IotHubClientMessage(new Message(payload.IsReadable() ? new ReadOnlyByteBufferStream(payload, false) : null), payload);
     message.Address = address;
     return message;
 }
开发者ID:nayato,项目名称:azure-iot-protocol-gateway,代码行数:6,代码来源:IotHubClient.cs

示例7: ValidateDelimiter

        static void ValidateDelimiter(IByteBuffer delimiter)
        {
            if (delimiter == null)
                throw new NullReferenceException("delimiter");

            if (!delimiter.IsReadable())
                throw new ArgumentException("empty delimiter");
        }
开发者ID:RabbitTeam,项目名称:DotNetty,代码行数:8,代码来源:DelimiterBasedFrameDecoder.cs

示例8: SynchronizeFrame

        /// <summary>
        /// Synchronizes the frame.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
        private static bool SynchronizeFrame(IByteBuffer input)
        {
            var count = 0;
            while (input.IsReadable())
            {
                count = (input.ReadByte() == 0xFF) ? count + 1 : 0;
                if (count >= FrameSyncBytes) return true;
            }

            ByteBlasterEventSource.Log.SynchronizationWarning(count);
            return false;
        }
开发者ID:bradsjm,项目名称:DotEmwin,代码行数:17,代码来源:ByteBlasterProtocolDecoder.cs

示例9: SkipNullBytes

        /// <summary>
        /// Skips the null bytes.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns><c>true</c> if successful, <c>false</c> otherwise.</returns>
        private static bool SkipNullBytes(IByteBuffer input)
        {
            while (input.IsReadable())
            {
                if (input.GetByte(input.ReaderIndex) != 0xFF) return true;
                input.SkipBytes(1);
            }

            return false;
        }
开发者ID:bradsjm,项目名称:DotEmwin,代码行数:15,代码来源:ByteBlasterProtocolDecoder.cs

示例10: Decode

        /// <summary>
        /// Decodes the byte buffer and builds QuickBlockTransfer packets.
        /// </summary>
        /// <param name="context">The handler context.</param>
        /// <param name="input">The input byte buffer from the socket.</param>
        /// <param name="output">The output packets.</param>
        protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
        {
            switch (State)
            {
                case DecoderState.ReSync:
                    if (!input.IsReadable(QuickBlockV1BodySize + FrameSyncBytes)) break;
                    PerformanceCounters.FrameSyncTotal.Increment();
                    if (!SynchronizeFrame(input)) break;
                    State = DecoderState.StartFrame;
                    goto case DecoderState.StartFrame;

                case DecoderState.StartFrame:
                    if (!SkipNullBytes(input)) break;
                    State = DecoderState.FrameType;
                    goto case DecoderState.FrameType;

                case DecoderState.FrameType:
                    if (!input.IsReadable(QuickBlockHeaderSize)) break;
                    if (IsDataBlockHeader(input))
                    {
                        State = DecoderState.BlockHeader;
                        goto case DecoderState.BlockHeader;
                    }
                    if (IsServerList(input))
                    {
                        PerformanceCounters.ServerListReceivedTotal.Increment();
                        State = DecoderState.ServerList;
                        goto case DecoderState.ServerList;
                    }
                    throw new InvalidOperationException("Unknown frame type");

                case DecoderState.ServerList:
                    var content = ReadString(input);
                    if (content.Length == 0) break;
                    context.FireUserEventTriggered(ParseServerList(content));
                    State = DecoderState.StartFrame;
                    goto case DecoderState.StartFrame;

                case DecoderState.BlockHeader:
                    Packet = ParsePacketHeader(input);
                    PerformanceCounters.BlocksReceivedTotal.Increment();
                    if (Packet.Version == 2)
                        PerformanceCounters.CompressedBlocksReceivedTotal.Increment();
                    State = DecoderState.BlockBody;
                    goto case DecoderState.BlockBody;

                case DecoderState.BlockBody:
                    if (!input.IsReadable(Packet.Length)) break;
                    Packet.Content = ReadPacketBody(input, Packet.Length, Packet.Version);
                    PerformanceCounters.BlocksProcessedPerSecond.Increment();
                    State = DecoderState.Validate;
                    goto case DecoderState.Validate;

                case DecoderState.Validate:
                    if (Packet.TotalBlocks <= 0 || Packet.BlockNumber <= 0)
                    {
                        PerformanceCounters.ChecksumErrorsTotal.Increment();
                        throw new InvalidDataException("Header block values out of range. " + Packet);
                    }

                    if (VerifyChecksum(Packet.Content, Packet.Checksum))
                    {
                        ByteBlasterEventSource.Log.PacketCreated(Packet.ToString());
                        context.FireUserEventTriggered(Packet);
                    }
                    else
                    {
                        PerformanceCounters.ChecksumErrorsTotal.Increment();
                        throw new InvalidDataException("Block Checksum failed. " + Packet);
                    }

                    State = DecoderState.StartFrame;
                    goto case DecoderState.StartFrame;

                default:
                    throw new InvalidOperationException("Unknown Decoder State: " + State);
            }
        }
开发者ID:bradsjm,项目名称:DotEmwin,代码行数:84,代码来源:ByteBlasterProtocolDecoder.cs


注:本文中的IByteBuffer.IsReadable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。