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


C# IoBuffer.Get方法代码示例

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


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

示例1: Decodable

        public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
        {
            if ((MessageType)input.Get() != MessageType.Update_ZipFiles)
            {
                return MessageDecoderResult.NotOK;
            }

            var zipFileInfo = JsonConvert.DeserializeObject<TransferingZipFileInfo>(input.GetString(Encoding.UTF8));
            var fileSize = zipFileInfo.FileSize;
            var hashBytes = zipFileInfo.HashBytes;
            if (input.Remaining < fileSize)
            {
                return MessageDecoderResult.NeedData;
            }

            var filesBytes = new byte[fileSize];
            input.Get(filesBytes, 0, (int)fileSize);

            if (FileHashHelper.CompareHashValue(FileHashHelper.ComputeFileHash(filesBytes), hashBytes))
            {
                _zipFileInfoMessage = new TransferingZipFile(filesBytes);
                return MessageDecoderResult.OK;
            }
            return MessageDecoderResult.NotOK;
        }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:25,代码来源:TransferingZipFileProtocolDecoder.cs

示例2: GetHexdump

        public static String GetHexdump(IoBuffer buf, Int32 lengthLimit)
        {
            if (lengthLimit <= 0)
                throw new ArgumentException("lengthLimit: " + lengthLimit + " (expected: 1+)");
            Boolean truncate = buf.Remaining > lengthLimit;
            Int32 size = truncate ? lengthLimit : buf.Remaining;

            if (size == 0)
                return "empty";

            StringBuilder sb = new StringBuilder(size * 3 + 3);
            Int32 oldPos = buf.Position;

            // fill the first
            Int32 byteValue = buf.Get() & 0xFF;
            sb.Append((char)highDigits[byteValue]);
            sb.Append((char)lowDigits[byteValue]);
            size--;

            // and the others, too
            for (; size > 0; size--)
            {
                sb.Append(' ');
                byteValue = buf.Get() & 0xFF;
                sb.Append((char)highDigits[byteValue]);
                sb.Append((char)lowDigits[byteValue]);
            }

            buf.Position = oldPos;

            if (truncate)
                sb.Append("...");

            return sb.ToString();
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:35,代码来源:IoBufferHexDumper.cs

示例3: Decode

        public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
        {
            if (input.HasRemaining)
                return FinishDecode(input.Get(), output);

            return this;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:7,代码来源:SingleByteDecodingState.cs

示例4: ComputeChecksum

 private byte ComputeChecksum(IoBuffer buffer)
 {
     buffer.Rewind();
     byte checksum = 0;
     for (int i = 0; i < Length - 1; i++) checksum += buffer.Get();
     return checksum;
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:7,代码来源:AbstractPacket.cs

示例5: Decodable

 public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
 {
     if ((MessageType)input.Get() != MessageType.Update_UpdateInfo)
     {
         return MessageDecoderResult.NotOK;
     }
     _appUdateInfo = (IClientInfo)JsonConvert.DeserializeObject(input.GetString(Encoding.UTF8));
     return MessageDecoderResult.OK;
 }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:9,代码来源:ClientInfoProtocolDecoder.cs

示例6: Decode

        public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
        {
            while (input.HasRemaining)
            {
                switch (_counter)
                {
                    case 0:
                        _highByte = input.Get() & 0xff;
                        break;
                    case 1:
                        _counter = 0;
                        return FinishDecode((Int16)((_highByte << 8) | (input.Get() & 0xff)), output);
                }

                _counter++;
            }
            return this;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:18,代码来源:ShortIntegerDecodingState.cs

示例7: ReadLocator

        public static void ReadLocator(IoBuffer buffer, ref Locator obj)
        {
            if (obj == null)
                obj = new Locator();
            obj.Kind = (LocatorKind)buffer.GetInt32();
            obj.Port = (int)buffer.GetInt32(); ;
            byte[] tmp = new byte[16];

            buffer.Get(tmp, 0, 16);
            obj.SocketAddressBytes = tmp;
        }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:11,代码来源:LocatorEncoder.cs

示例8: Decodable

 public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
 {
     var type=(MessageType)input.Get();
     if (type==MessageType.Update_FileHash)
     {
         var message = input.GetString(Encoding.UTF8);
         _decodeMessage=JsonConvert.DeserializeObject<IList<IFileHash>>(message);
         return MessageDecoderResult.OK;
     }
     return MessageDecoderResult.NotOK;
 }
开发者ID:AnchoretTeam,项目名称:AppUpdate,代码行数:11,代码来源:FileHashesProtocolDecoder.cs

示例9: Decode

        public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
        {
            Boolean found = false;
            Boolean finished = false;
            while (input.HasRemaining)
            {
                Byte b = input.Get();
                if (!_hasCR)
                {
                    if (b == CR)
                    {
                        _hasCR = true;
                    }
                    else
                    {
                        if (b == LF)
                        {
                            found = true;
                        }
                        else
                        {
                            input.Position = input.Position - 1;
                            found = false;
                        }
                        finished = true;
                        break;
                    }
                }
                else
                {
                    if (b == LF)
                    {
                        found = true;
                        finished = true;
                        break;
                    }

                    throw new ProtocolDecoderException("Expected LF after CR but was: " + (b & 0xff));
                }
            }

            if (finished)
            {
                _hasCR = false;
                return FinishDecode(found, output);
            }

            return this;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:49,代码来源:CrLfDecodingState.cs

示例10: Decodable

 public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
 {
     if (input.Remaining < MIN_PACKET_LENGTH)
         return MessageDecoderResult.NeedData;
     var symbol = input.GetArray(2);
     if (DataPacket.True(symbol))
     {
         input.Skip(1);
         var len = input.Get();
         input.Rewind();
         if (len > input.Remaining) return MessageDecoderResult.NeedData;
     }
     else if (!CtlPacket.True(symbol)) return MessageDecoderResult.NotOK;
     return MessageDecoderResult.OK;
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:15,代码来源:PacketDecoder.cs

示例11: Decode

        public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
        {
            while (input.HasRemaining)
            {
                switch (_counter)
                {
                    case 0:
                        _firstByte = input.Get() & 0xff;
                        break;
                    case 1:
                        _secondByte = input.Get() & 0xff;
                        break;
                    case 2:
                        _thirdByte = input.Get() & 0xff;
                        break;
                    case 3:
                        _counter = 0;
                        return FinishDecode((_firstByte << 24) | (_secondByte << 16) | (_thirdByte << 8) | (input.Get() & 0xff), output);
                }

                _counter++;
            }
            return this;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:24,代码来源:IntegerDecodingState.cs

示例12: Decode

 public MessageDecoderResult Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
 {
     int limit = input.Limit;
     int position = input.Position;
     var len = input.GetInt32();
     var version = input.Get();
     input.Position = position;
     input.Limit = input.Position + len;
     var buffer = input.Slice();
     input.Position = input.Limit;
     input.Limit = limit;
     var message = DoDecode(version.ToEnum<MessageVersion>(), buffer);
     if (message != null)
         output.Write(message);
     return MessageDecoderResult.OK;
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:16,代码来源:AbstractMessageDecoder.cs

示例13: Decodable

        public MessageDecoderResult Decodable(IoSession session, IoBuffer input)
        {
            if (input.Remaining < MESSAGE_LENGTH_BYTES_LENGTH)
                return MessageDecoderResult.NeedData;
            var len = input.GetInt32();
            if (len > MAX_MESSAGE_LENGTH)
                return MessageDecoderResult.NotOK;
            if (input.Remaining + MESSAGE_LENGTH_BYTES_LENGTH < len)
                return MessageDecoderResult.NeedData;
            var version = input.Get().ToEnum<MessageVersion>();
            if (version == MessageVersion.BadVersion)
                return MessageDecoderResult.NotOK;
            if (len < FixedHeaderLength(version))
                return MessageDecoderResult.NotOK;

            return MessageDecoderResult.OK;
        }
开发者ID:zesus19,项目名称:c5.v1,代码行数:17,代码来源:AbstractMessageDecoder.cs

示例14: ReadVarint32

        static uint ReadVarint32(IoBuffer buffer)
        {
            int result = 0;
            int offset = 0;

            for (; offset < 32; offset += 7)
            {
                int b = buffer.Get();
                if (b == -1)
                    throw new BufferUnderflowException();

                result |= (b & 0x7f) << offset;

                if ((b & 0x80) == 0)
                    return (uint)result;
            }

            throw new InvalidDataException();
        }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:19,代码来源:Primitives.cs

示例15: ReadVarint64

        static ulong ReadVarint64(IoBuffer buffer)
        {
            long result = 0;
            int offset = 0;

            for (; offset < 64; offset += 7)
            {
                int b = buffer.Get();
                if (b == -1)
                    throw new BufferUnderflowException();

                result |= ((long)(b & 0x7f)) << offset;

                if ((b & 0x80) == 0)
                    return (ulong)result;
            }

            throw new InvalidDataException();
        }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:19,代码来源:Primitives.cs


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