本文整理汇总了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;
}
示例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();
}
示例3: Decode
public IDecodingState Decode(IoBuffer input, IProtocolDecoderOutput output)
{
if (input.HasRemaining)
return FinishDecode(input.Get(), output);
return this;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}