当前位置: 首页>>代码示例>>C#>>正文


C# ByteBuffer.appendInt方法代码示例

本文整理汇总了C#中System.ByteBuffer.appendInt方法的典型用法代码示例。如果您正苦于以下问题:C# ByteBuffer.appendInt方法的具体用法?C# ByteBuffer.appendInt怎么用?C# ByteBuffer.appendInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ByteBuffer的用法示例。


在下文中一共展示了ByteBuffer.appendInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: append

 private static void append(object field, ref ByteBuffer buff)
 {
     Type type = field.GetType();
     switch (type.FullName)
     {
         case "System.Int16":
             buff.appendShort((short)field);
             break;
         case "System.Int32":
             buff.appendInt((int)field);
             break;
         case "System.Int64":
             buff.appendLong((long)field);
             break;
         case "System.UInt16":
             buff.appendUshort((ushort)field);
             break;
         case "System.UInt32":
             buff.appendUint((uint)field);
             break;
         //case "System.UInt64":
         //    buff.appendUlong((ulong)field);
         //    break;
         case "System.Byte":
             buff.appendByte((byte)field);
             break;
         case "System.Boolean":
             buff.appendBool((bool)field);
             break;
         case "System.Single":
             buff.appendFloat((float)field);
             break;
         case "System.Double":
             buff.appendDouble((double)field);
             break;
         case "System.String":
             buff.appendString((string)field);
             break;
         default:
             throw new Exception("协议包含不可解析类型:" + type.FullName);
     }
 }
开发者ID:xqy,项目名称:game,代码行数:42,代码来源:PackageUtil.cs

示例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;
        }
开发者ID:xqy,项目名称:game,代码行数:24,代码来源:SocketManager.cs


注:本文中的System.ByteBuffer.appendInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。