Beispiel #1
0
        public void SendCommand <T>(uint id1, uint id2, T cmd)
        {
            byte[] pbdata = ProtoBufSerialize.Serialize(cmd);
            sendCache.Clear();

            CUtility.UInt8ToBytes(id1, sendCache);
            CUtility.UInt8ToBytes(id2, sendCache);
            CUtility.UInt32ToBytes(AddSendPackCount(), sendCache);
            CUtility.BytesToBytes(pbdata, pbdata.Length, sendCache);

            Send(sendCache.ToArray());
        }
Beispiel #2
0
        public static byte[] Wrap(byte[] message, int packHeadLen = 3)
        {
            if (message == null)
            {
                return(null);
            }

            uint msgLength = (uint)message.Length;

            if ((PacketConstDefine.SendSerializeType & SerializeType.Compress) != 0)
            {
            }
            if ((PacketConstDefine.SendSerializeType & SerializeType.Encript) != 0)
            {
            }

            dataCache.Clear();
            uint flag = 0;

            CUtility.UInt8ToBytes(flag, dataCache);
            CUtility.UInt16ToBytes(msgLength, dataCache);
            CUtility.BytesToBytes(message, (int)msgLength, dataCache);
            return(dataCache.ToArray());
        }