本文整理汇总了C#中Lidgren.Network.NetBuffer.WriteVariableUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# NetBuffer.WriteVariableUInt64方法的具体用法?C# NetBuffer.WriteVariableUInt64怎么用?C# NetBuffer.WriteVariableUInt64使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetBuffer
的用法示例。
在下文中一共展示了NetBuffer.WriteVariableUInt64方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//.........这里部分代码省略.........
throw new Exception("Ack thphth ReadInt32 2");
if (msg.ReadInt32(5) != 0)
throw new Exception("Ack thphth ReadInt32 3");
if (msg.ReadInt32(5) != -1)
throw new Exception("Ack thphth ReadInt32 4");
if (msg.ReadInt32(5) != -2)
throw new Exception("Ack thphth ReadInt32 5");
if (msg.ReadInt32(5) != -15)
throw new Exception("Ack thphth ReadInt32 6");
UInt64 longVal = msg.ReadUInt64();
if (longVal != UInt64.MaxValue)
throw new Exception("Ack thphth UInt64");
if (msg.ReadInt64() != Int64.MaxValue)
throw new Exception("Ack thphth Int64");
if (msg.ReadInt64() != Int64.MinValue)
throw new Exception("Ack thphth Int64");
if (msg.ReadInt32() != 42)
throw new Exception("Ack thphth end");
msg.SkipPadBits();
if (msg.ReadRangedInteger(0, 10) != 5)
throw new Exception("Ack thphth ranged integer");
}
// test writevariableuint64
NetBuffer largeBuffer = new NetBuffer(100 * 8);
UInt64[] largeNumbers = new ulong[100];
for (int i = 0; i < 100; i++)
{
largeNumbers[i] = ((ulong)NetRandom.Instance.NextUInt() << 32) | (ulong)NetRandom.Instance.NextUInt();
largeBuffer.WriteVariableUInt64(largeNumbers[i]);
}
largeBuffer.Position = 0;
for (int i = 0; i < 100; i++)
{
UInt64 ln = largeBuffer.ReadVariableUInt64();
if (ln != largeNumbers[i])
throw new Exception("large fail");
}
//
// Extended tests on padbits
//
for (int i = 1; i < 31; i++)
{
NetBuffer buf = new NetBuffer();
buf.Write((int)1, i);
if (buf.LengthBits != i)
throw new Exception("Bad length!");
buf.WritePadBits();
int wholeBytes = buf.LengthBits / 8;
if (wholeBytes * 8 != buf.LengthBits)
throw new Exception("WritePadBits failed! Length is " + buf.LengthBits);
}
NetBuffer small = new NetBuffer(100);
byte[] rnd = new byte[24];
int[] bits = new int[24];
for (int i = 0; i < 24; i++)
{