本文整理匯總了C#中System.ByteBuffer.removeUshort方法的典型用法代碼示例。如果您正苦於以下問題:C# ByteBuffer.removeUshort方法的具體用法?C# ByteBuffer.removeUshort怎麽用?C# ByteBuffer.removeUshort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.ByteBuffer
的用法示例。
在下文中一共展示了ByteBuffer.removeUshort方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: getArray
private static object getArray(ref ByteBuffer buff, string itemTypeName)
{
//數組長度
int len = buff.removeUshort();
//C#類型
Type itemType = Type.GetType(itemTypeName, false);
if (itemType != null)
{
object[] array = new object[len];
for (int i = 0; i < len; i++)
{
array[i] = getValue(ref buff, itemType);
}
return array;
}
//L#類型
ICLRType clrType = CLRSharpManager.instance.getCLRType(itemTypeName);
if (clrType != null)
{
object[] array = new object[len];
for (int i = 0; i < len; i++)
{
array[i] = byteBufferToClrObject(ref buff, clrType);
}
return array;
}
throw new Exception("協議包含不可解析類型:" + itemTypeName + "[]");
}
示例2: getValue
private static object getValue(ref ByteBuffer buff, Type type)
{
switch (type.FullName)
{
case "System.Int16":
return buff.removeShort();
case "System.Int32":
return buff.removeInt();
case "System.Int64":
return buff.removeLong();
case "System.UInt16":
return buff.removeUshort();
case "System.UInt32":
return buff.removeUint();
//case "System.UInt64":
// return buff.removeUlong();
case "System.Byte":
return buff.removeByte();
case "System.Boolean":
return buff.removeBool();
case "System.Single":
return buff.removeFloat();
case "System.Double":
return buff.removeDouble();
case "System.String":
return buff.removeString();
default:
throw new Exception("協議包含不可解析類型:" + type.FullName);
}
}
示例3: unpack
/// <summary>
/// 拆包,時間戳 + 協議號 + 內容長度 + 內容
/// </summary>
/// <param name="buff"></param>
/// <returns></returns>
private Package unpack(ByteBuffer buff)
{
Package package = new Package();
package.timeStamp = buff.removeInt();
package.protocol = buff.removeInt();
package.len = buff.removeUshort();
if (buff.length < package.len)
{
throw new Exception("協議" + package.protocol +
"包體字節長度不對,應是" + package.len + ",但當前是" + buff.length);
}
if (listenDic.ContainsKey(package.protocol))
{
package.data = PackageUtil.byteBufferToClrObject(ref buff, listenDic[package.protocol].clrType);
Debug.Log("[接收] " + package.toString());
}
else
{
Debug.Log("[接收,未處理] " + package.toString());
}
return package;
}