本文整理汇总了C#中Mina.Core.Buffer.IoBuffer类的典型用法代码示例。如果您正苦于以下问题:C# IoBuffer类的具体用法?C# IoBuffer怎么用?C# IoBuffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IoBuffer类属于Mina.Core.Buffer命名空间,在下文中一共展示了IoBuffer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Decode
public void Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
{
if (_session == null)
_session = session;
else if (_session != session)
throw new InvalidOperationException(GetType().Name + " is a stateful decoder. "
+ "You have to create one per session.");
_undecodedBuffers.Enqueue(input);
while (true)
{
IoBuffer b;
if (!_undecodedBuffers.TryPeek(out b))
break;
Int32 oldRemaining = b.Remaining;
_state.Decode(b, output);
Int32 newRemaining = b.Remaining;
if (newRemaining != 0)
{
if (oldRemaining == newRemaining)
throw new InvalidOperationException(_state.GetType().Name
+ " must consume at least one byte per decode().");
}
else
{
_undecodedBuffers.TryDequeue(out b);
}
}
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:30,代码来源:DecodingStateProtocolDecoder.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: 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
示例4: Decode
public void Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
{
lock (_decoder)
{
_decoder.Decode(session, input, output);
}
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:7,代码来源:SynchronizedProtocolDecoder.cs
示例5: Decode
public MessageDecoderResult Decode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
{
// Try to skip header if not read.
if (!_readHeader)
{
input.GetInt16(); // Skip 'type'.
_sequence = input.GetInt32(); // Get 'sequence'.
_readHeader = true;
}
// Try to decode body
AbstractMessage m = DecodeBody(session, input);
// Return NEED_DATA if the body is not fully read.
if (m == null)
{
return MessageDecoderResult.NeedData;
}
else
{
_readHeader = false; // reset readHeader for the next decode
}
m.Sequence = _sequence;
output.Write(m);
return MessageDecoderResult.OK;
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:26,代码来源:AbstractMessageDecoder.cs
示例6: IoBufferWrapper
/// <summary>
/// </summary>
protected IoBufferWrapper(IoBuffer buf)
: base(-1, 0, 0, 0)
{
if (buf == null)
throw new ArgumentNullException("buf");
_buf = buf;
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:9,代码来源:IoBufferWrapper.cs
示例7: DecodeBody
protected override AbstractMessage DecodeBody(IoSession session, IoBuffer input)
{
if (!_readCode)
{
if (input.Remaining < Constants.RESULT_CODE_LEN)
{
return null; // Need more data.
}
_code = input.GetInt16();
_readCode = true;
}
if (_code == Constants.RESULT_OK)
{
if (input.Remaining < Constants.RESULT_VALUE_LEN)
{
return null;
}
ResultMessage m = new ResultMessage();
m.OK = true;
m.Value = input.GetInt32();
_readCode = false;
return m;
}
else
{
ResultMessage m = new ResultMessage();
m.OK = false;
_readCode = false;
return m;
}
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:34,代码来源:ResultMessageDecoder.cs
示例8: BeginSend
/// <inheritdoc/>
protected override void BeginSend(IWriteRequest request, IoBuffer buf)
{
EndPoint destination = request.Destination;
if (destination == null)
destination = this.RemoteEndPoint;
BeginSend(buf, destination);
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:8,代码来源:AsyncDatagramSession.cs
示例9: 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
示例10: 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
示例11: DoDecode
protected override object DoDecode(MessageVersion version, IoBuffer input)
{
using (var scope = ObjectHost.Host.BeginLifetimeScope())
{
return scope.ResolveKeyed<IMessageReader<DuplexMessage>>(version).Read(input);
}
}
开发者ID:zesus19,项目名称:c5.v1,代码行数:7,代码来源:DuplexMessageDecoder.cs
示例12: 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
示例13: IoSessionStream
/// <summary>
/// </summary>
public IoSessionStream()
{
_syncRoot = new Byte[0];
_buf = IoBuffer.Allocate(16);
_buf.AutoExpand = true;
_buf.Limit = 0;
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:9,代码来源:IoSessionStream.cs
示例14: 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
示例15: ParameterListEncapsulation
internal ParameterListEncapsulation(IoBuffer bb)
{
#if TODO
this.options = bb.GetInt16();
this.parameters = bb.GetParameterList();
#endif
throw new NotImplementedException();
}
开发者ID:Egipto87,项目名称:DOOP.ec,代码行数:8,代码来源:ParameterListEncapsulation.cs
示例16: 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
示例17: 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
示例18: DoDecode
/// <inheritdoc/>
protected override Boolean DoDecode(IoSession session, IoBuffer input, IProtocolDecoderOutput output)
{
if (!input.PrefixedDataAvailable(4, _maxObjectSize))
return false;
input.GetInt32();
output.Write(input.GetObject());
return true;
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:10,代码来源:ObjectSerializationDecoder.cs
示例19: DecodeBody
protected override Message.AbstractMessage DecodeBody(IoSession session, IoBuffer input)
{
if (input.Remaining < Constants.ADD_BODY_LEN)
{
return null;
}
AddMessage m = new AddMessage();
m.Value = input.GetInt32();
return m;
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:11,代码来源:AddMessageDecoder.cs
示例20: TestDecoderAndInputStream
private void TestDecoderAndInputStream(String expected, IoBuffer input)
{
// Test ProtocolDecoder
IProtocolDecoder decoder = new ObjectSerializationDecoder();
ProtocolCodecSession session = new ProtocolCodecSession();
IProtocolDecoderOutput decoderOut = session.DecoderOutput;
decoder.Decode(session, input.Duplicate(), decoderOut);
Assert.AreEqual(1, session.DecoderOutputQueue.Count);
Assert.AreEqual(expected, session.DecoderOutputQueue.Dequeue());
}
开发者ID:zhangf911,项目名称:Mina.NET,代码行数:11,代码来源:ObjectSerializationTest.cs
注:本文中的Mina.Core.Buffer.IoBuffer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论