本文整理汇总了C#中System.ByteBuffer.appendBuffer方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.appendBuffer方法的具体用法?C# ByteBuffer.appendBuffer怎么用?C# ByteBuffer.appendBuffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.appendBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: appendField
private static void appendField(object field, ref ByteBuffer buff)
{
if (field is CLRSharp_Instance)
{
buff.appendBuffer(clrObjectToByteBuffer(field as CLRSharp_Instance));
}
else
{
Type type = field.GetType();
if (type.BaseType != null && type.BaseType.FullName == "System.Array")
{
appendArray(field as Array, ref buff);
}
else
{
append(field, ref buff);
}
}
}
示例2: packet
/// <summary>
/// 封包,时间戳 + 协议号 + 内容长度 + 内容
/// </summary>
/// <param name="protocol"></param>
/// <param name="data"></param>
/// <returns></returns>
private ByteBuffer packet(int protocol, object data)
{
ByteBuffer buff = PackageUtil.clrObjectToByteBuffer(data as CLRSharp_Instance);
Package package = new Package();
package.timeStamp = TimeUtil.getTimeStamp();
package.protocol = protocol;
package.len = (ushort)buff.length;
package.data = data;
Debug.Log("[发送] " + package.toString());
ByteBuffer buffer = new ByteBuffer();
buffer.appendInt(package.timeStamp);
buffer.appendInt(package.protocol);
buffer.appendUshort(package.len);
buffer.appendBuffer(buff);
return buffer;
}