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


C# IoBuffer.Put方法代码示例

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


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

示例1: WriteVarint32

        static void WriteVarint32(IoBuffer buffer, uint value)
        {
            for (; value >= 0x80u; value >>= 7)
                buffer.Put((byte)(value | 0x80u));

            buffer.Put((byte)value);
        }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:7,代码来源:Primitives.cs

示例2: Fill

 protected override void Fill(IoBuffer buffer)
 {
     buffer.Put(Length);
     buffer.Put(FRAME_SOURCE_ADDR);
     buffer.Put(Protocol);
     buffer.Put(FRAME_SEQUENCE_VALUE);
     this.FillData(buffer);
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:8,代码来源:DataPacket.cs

示例3: Decode

        public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
        {
            if (_buffer == null)
            {
                if (input.Remaining >= _length)
                {
                    Int32 limit = input.Limit;
                    input.Limit = input.Position + _length;
                    IoBuffer product = input.Slice();
                    input.Position = input.Position + _length;
                    input.Limit = limit;
                    return FinishDecode(product, output);
                }

                _buffer = IoBuffer.Allocate(_length);
                _buffer.Put(input);
                return this;
            }

            if (input.Remaining >= _length - _buffer.Position)
            {
                Int32 limit = input.Limit;
                input.Limit = input.Position + _length - _buffer.Position;
                _buffer.Put(input);
                input.Limit = limit;
                IoBuffer product = _buffer;
                _buffer = null;
                return FinishDecode(product.Flip(), output);
            }

            _buffer.Put(input);
            return this;
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:33,代码来源:FixedLengthDecodingState.cs

示例4: Read

 /// <inheritdoc/>
 public Int32 Read(IoBuffer buffer)
 {
     using (FileStream fs = _file.OpenRead())
     {
         fs.Position = _position;
         Byte[] bytes = new Byte[buffer.Remaining];
         Int32 read = fs.Read(bytes, 0, bytes.Length);
         buffer.Put(bytes, 0, read);
         Update(read);
         return read;
     }
 }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:13,代码来源:FileInfoFileRegion.cs

示例5: WriteProtocolId

 public static void WriteProtocolId(IoBuffer buffer, ProtocolId obj)
 {
     buffer.Put(obj.Id);
 }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:4,代码来源:ProtocolIdEncoder.cs

示例6: ManipulateIoBuffer

        private void ManipulateIoBuffer(IoSession session, IoBuffer buffer)
        {
            if ((buffer.Remaining > 0) && (_removeByteProbability > _rng.Next(1000)))
            {
                if (log.IsInfoEnabled)
                    log.Info(buffer.GetHexDump());

                // where to remove bytes ?
                int pos = _rng.Next(buffer.Remaining);
                // how many byte to remove ?
                int count = _rng.Next(buffer.Remaining - pos) + 1;
                if (count == buffer.Remaining)
                    count = buffer.Remaining - 1;

                IoBuffer newBuff = IoBuffer.Allocate(buffer.Remaining - count);
                for (int i = 0; i < pos; i++)
                    newBuff.Put(buffer.Get());

                buffer.Skip(count); // hole
                while (newBuff.Remaining > 0)
                    newBuff.Put(buffer.Get());
                newBuff.Flip();
                // copy the new buffer in the old one
                buffer.Rewind();
                buffer.Put(newBuff);
                buffer.Flip();

                if (log.IsInfoEnabled)
                {
                    log.Info("Removed " + count + " bytes at position " + pos + ".");
                    log.Info(buffer.GetHexDump());
                }
            }
            if ((buffer.Remaining > 0) && (_changeByteProbability > _rng.Next(1000)))
            {
                if (log.IsInfoEnabled)
                    log.Info(buffer.GetHexDump());

                // how many byte to change ?
                int count = _rng.Next(buffer.Remaining - 1) + 1;

                byte[] values = new byte[count];
                _rng.NextBytes(values);
                for (int i = 0; i < values.Length; i++)
                {
                    int pos = _rng.Next(buffer.Remaining);
                    buffer.Put(pos, values[i]);
                }

                if (log.IsInfoEnabled)
                {
                    log.Info("Modified " + count + " bytes.");
                    log.Info(buffer.GetHexDump());
                }
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:56,代码来源:ErrorGeneratingFilter.cs

示例7: WriteGuidPrefix

 public static void WriteGuidPrefix(IoBuffer buffer, GuidPrefix obj)
 {
     buffer.Put(obj.Prefix);
 }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:4,代码来源:GuidPrefixEncoder.cs

示例8: Write

        private void Write(IoSession session, IoBuffer data, IoBuffer buf)
        {
            try
            {
                Int32 len = data.Remaining;
                if (len >= buf.Capacity)
                {
                    /*
                     * If the request length exceeds the size of the output buffer,
                     * flush the output buffer and then write the data directly.
                     */
                    INextFilter nextFilter = session.FilterChain.GetNextFilter(this);
                    InternalFlush(nextFilter, session, buf);
                    nextFilter.FilterWrite(session, new DefaultWriteRequest(data));
                    return;
                }
                if (len > (buf.Limit - buf.Position))
                {
                    InternalFlush(session.FilterChain.GetNextFilter(this), session, buf);
                }

                lock (buf)
                {
                    buf.Put(data);
                }
            }
            catch (Exception e)
            {
                session.FilterChain.FireExceptionCaught(e);
            }
        }
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:31,代码来源:BufferedWriteFilter.cs

示例9: FillData

 protected override void FillData(IoBuffer buffer)
 {
     buffer.Put(addrChangeTo);
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:4,代码来源:AddrAssignDataPacket.cs

示例10: WriteLocator

 public static void WriteLocator(IoBuffer buffer, Locator obj)
 {
     buffer.PutInt32((int)obj.Kind);
     buffer.PutInt32(obj.Port);
     buffer.Put(obj.SocketAddressBytes);
 }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:6,代码来源:LocatorEncoder.cs

示例11: WritePrimitive

        public static void WritePrimitive(IoBuffer buffer, byte[] value)
        {
            if (value == null)
            {
                WritePrimitive(buffer, (uint)0);
                return;
            }

            WritePrimitive(buffer, (uint)value.Length + 1);

            buffer.Put(value, 0, value.Length);
        }
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:12,代码来源:Primitives.cs

示例12: Fill

 protected override void Fill(IoBuffer buffer)
 {
     buffer.Put(FRAME_SOURCE_ADDR);
     buffer.Put(Respond);
     buffer.Put(FRAME_SEQUENCE_VALUE);
 }
开发者ID:zesus19,项目名称:c5.v1,代码行数:6,代码来源:CtlPacket.cs


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