Bonjour,
J'ai absolument besoin de récupérer les données contenu dans ce message mais pour je ne sais quelle raison je ne le recoi pas.
Logs:
6:55:01 : LOCAL - Id: 4 Length: 276
6:55:01 : LOCAL - Id: 5607 Length: 23
6:55:02 : LOCAL - Id: 40 Length: 1
6:55:03 : GAME - Id: 1 Length: 8
6:55:03 : LOCAL - Id: 110 Length: 38
6:55:03 : GAME - Id: 8903 Length: 7
6:55:03 : GAME - Id: 3734 Length: 35
6:55:03 : GAME - Id: 7703 Length: 28
6:55:03 : GAME - Id: 3143 Length: 200
6:55:05 : LOCAL - Id: 6372 Length: 258
6:55:05 : GAME - Id: 6769 Length: 21
6:55:05 : GAME - Id: 6649 Length: 38
6:55:06 : GAME - Id: 6100 Length: 4
6:55:06 : GAME - Id: 6100 Length: 4
6:55:11 : LOCAL - Id: 152 Length: 6
6:55:11 : GAME - Id: 6100 Length: 4
6:55:11 : GAME - Id: 6860 Length: 7
6:55:11 : GAME - Id: 6087 Length: 6
6:55:12 : GAME - Id: 883 Length: 91
6:55:12 : GAME - Id: 4002 Length: 164
6:55:12 : GAME - Id: 6820 Length: 2
6:55:12 : GAME - Id: 5674 Length: 2
6:55:13 : LOCAL - Id: 5607 Length: 71
6:55:13 : GAME - Id: 200 Length: 1
Classe pour décoder les packets:
public class Packet
{
public bool IsValid
{
get
{
return Header.HasValue && Length.HasValue &&
Length == Data.Length;
}
}
public int? MessageId
{
get
{
if (!Header.HasValue)
return null;
return Header >> 2;
}
}
public string Name
{
get
{
if (!MessageId.HasValue)
return null;
return PacketNames.GetClasseName((int)MessageId);
}
}
public ushort? Header { get; set; }
public uint Count { get; set; }
public int? Length { get; set; }
public byte[] Data
{
get { return m_data; }
private set { m_data = value; }
}
private byte[] m_data;
public bool Parse(BigEndianReader reader, bool isClient)
{
if (IsValid)
return true;
if (reader.BytesAvailable >= 2 && !Header.HasValue)
{
Header = reader.ReadUShort();
}
if (isClient)
Count = reader.ReadUInt();
var dataLengthBytesCount = Header & 0x3;
if (reader.BytesAvailable >= dataLengthBytesCount)
{
if (dataLengthBytesCount < 0 || dataLengthBytesCount > 3)
throw new ArgumentOutOfRangeException(nameof(dataLengthBytesCount));
Length = 0;
for (var i = dataLengthBytesCount - 1; i >= 0; i--)
Length |= reader.ReadByte() << (i * 8);
}
if (Length <= 0) return false;
if (Data == null && Length >= 0)
{
if (Length == 0)
Data = new byte[0];
if (reader.BytesAvailable >= Length)
{
Data = reader.ReadBytes(Length.Value);
}
else if (Length > reader.BytesAvailable)
Data = reader.ReadBytes((int)reader.BytesAvailable);
}
// Message divisé !
if (Data != null && Length != 0 && Data.Length < Length)
{
var bytesToRead = 0;
if (Data.Length + reader.BytesAvailable < Length)
bytesToRead = (int)reader.BytesAvailable;
else if (Data.Length + reader.BytesAvailable >= Length)
bytesToRead = (int)Length - Data.Length;
if (bytesToRead != 0)
{
var oldLength = Data.Length;
Array.Resize(ref m_data, (Data.Length + bytesToRead));
Array.Copy(reader.ReadBytes(bytesToRead), 0, Data, oldLength, bytesToRead);
}
}
return IsValid;
}
}
Peut être que la méthode que j'utilise pour analyser les packets n'est plus à jour ?
Si quelqu'un à une idée là dessus. Merci !