Bonjour !
J'ai un gros problème de lecture des packets
Ce que je recoi dans ma console :
[6:13:13] [Game] Id: 226 | Count: 0 | Length: 322
[6:13:13] [Game] Id: 6440 | Count: 0 | Length: 13867
[6:13:13] [Game] Id: 0 | Count: 0 | Length: 0
[6:13:13] [Game] Id: 6237 | Count: 0 | Length: 0
[6:13:13] [Game] Id: 6492 | Count: 0 | Length: 24948
[6:13:13] [Game] Id: 11072 | Count: 0 | Length: 251
[6:13:13] [Game] Id: 144 | Count: 0 | Length: 13166217
[6:13:13] [Game] Id: 512 | Count: 0 | Length: 0
[6:13:13] [Game] Id: 0 | Count: 0 | Length: 0
[6:13:13] [Game] Id: 320 | Count: 0 | Length: 0
[6:13:13] [Game] Id: 64 | Count: 0 | Length: 1
[6:13:13] [Game] Id: 16063 | Count: 0 | Length: 196608
[6:13:14] [Local] Id: 6648 | Count: 675 | Length: 0
[6:13:14] [Game] Id: 176 | Count: 0 | Length: 0
[6:13:14] [Game] Id: 6649 | Count: 0 | Length: 38
[6:13:16] [Game] Id: 883 | Count: 0 | Length: 110
Certains arrivent à bien être décodés d'autres non comme vous pouvez le voir. Ce qui me donne des tailles & id délirantes. x)
Voici comment je décode les packets:
Message msg = new Message();
BigEndianReader reader = new BigEndianReader(buffer);
ushort header = reader.ReadUShort();
int id = header >> 2;
msg.Header = header;
msg.Id = id;
if (isClient)
msg.Count = reader.ReadUInt();
int length = 0;
switch (header & 3)
{
case 1:
length = reader.ReadSByte();
break;
case 2:
length = reader.ReadUShort();
break;
case 3:
length = (reader.ReadByte() << 16) + (reader.ReadByte() << 8) + reader.ReadByte();
break;
}
msg.Length = length;
byte[] data = (length > 0) ? reader.ReadBytes(length) : new byte[] { };
msg.Data = data;
return msg;
Si quelqu'un peut m'aider. ^^