Example #1
0
        public void Serialize()
        {
            IMessage _proto = null;

            if (_protoBuilder != null)
            {
                _proto = _protoBuilder.WeakBuild();
                if (moduleId == 0 && subId == 1)
                {
                }
                else
                {
                    Debug.Log(" <color=#00ff00ff>" + "Send Msg:" + moduleId + "-" + subId + "proto:" + "</color>" + Encoding.UTF8.GetString(Encoding.UTF8.GetBytes(_proto.ToString())));
                }
                _protoBuilder = null;
            }
            byte[] buf = (_proto == null) ? BuffEmpty : _proto.ToByteArray();
//            for (int i = 0; i < buf.Length; i++)
//            {
//                Debug.Log(string.Format("<color=#ffffffff><---{0}-{1}----></color>", buf[i], "test1"));
//            }
            ByteArray ba = new ByteArray(HEAD_SIZE + buf.Length);

            //ba.WriteByte(0xAF);
            //ba.WriteByte(0xFE);
            ba.WriteByte(0x01);
            //ba.WriteInt(GameCode);//gamecode
            ba.WriteByte(moduleId);
            ba.WriteByte(subId);

            ba.WriteByte(1);

            ba.WriteInt(buf.Length);

            ba.WriteBytes(buf, buf.Length, false);

            raw = ba.Buff;
        }