Пример #1
0
 public byte[] Encode()
 {
     using (ByteStreamWriter writer = new ByteStreamWriter())
     {
         writer.WriteShort(data.Length + 35);   //version(2)+roleId(8)+SessionID(4)+sequence(8)+gameVersion(2)+resVersion(4)+platform(1)+protocalCode(4) = 33
         writer.WriteShort(version);
         writer.WriteLong(playerId);
         writer.WriteInt(sessionId);
         writer.WriteLong(sequence);
         writer.WriteShort(gameVersion);
         writer.WriteInt(resVersion);
         writer.WriteByte(platform);
         writer.WriteInt(protocalCode);
         writer.WriteBytes(data);
         //Jiawen: optimise GetBuff function to save some new operations.
         return(writer.GetBuffer());
     }
 }
Пример #2
0
        public byte[] Encode()
        {
            using (ByteStreamWriter writer = new ByteStreamWriter())
            {
                writer.WriteShort(data.Length + 48);   //version(2)+roleId(8)+SessionID(4)+sequence(8)+ack(8)+protocalCode(4)+endSequence(8)+checkSum(4) = 46
                writer.WriteShort(version);
                writer.WriteLong(playerId);
                writer.WriteInt(sessionId);
                writer.WriteLong(sequence);
                writer.WriteLong(ack);
                writer.WriteInt(protocalCode);
                writer.WriteLong(endSequence);
                //TODO: calculate checkSum.
                writer.WriteInt(checkSum);
                writer.WriteBytes(data);

                //Jiawen: optimise GetBuff function to save some new operations.
                return(writer.GetBuffer());
            }
        }