本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例5: WriteProtocolId
public static void WriteProtocolId(IoBuffer buffer, ProtocolId obj)
{
buffer.Put(obj.Id);
}
示例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());
}
}
}
示例7: WriteGuidPrefix
public static void WriteGuidPrefix(IoBuffer buffer, GuidPrefix obj)
{
buffer.Put(obj.Prefix);
}
示例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);
}
}
示例9: FillData
protected override void FillData(IoBuffer buffer)
{
buffer.Put(addrChangeTo);
}
示例10: WriteLocator
public static void WriteLocator(IoBuffer buffer, Locator obj)
{
buffer.PutInt32((int)obj.Kind);
buffer.PutInt32(obj.Port);
buffer.Put(obj.SocketAddressBytes);
}
示例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);
}
示例12: Fill
protected override void Fill(IoBuffer buffer)
{
buffer.Put(FRAME_SOURCE_ADDR);
buffer.Put(Respond);
buffer.Put(FRAME_SEQUENCE_VALUE);
}