Skip to content

Commit 46e4cc7

Browse files
committed
Merge pull request #33 from ziellos2k/develop
Develop
2 parents 7af0957 + a897d39 commit 46e4cc7

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

BattleNET/BattlEyeClient.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,16 @@ private int SendCommandPacket(string command, bool log = true)
169169

170170
byte[] packet = ConstructPacket(BattlEyePacketType.Command, sequenceNumber, command);
171171

172-
socket.Send(packet);
173172
packetSent = DateTime.Now;
174173

175174
if (log)
176175
{
177-
packetQueue.Add(sequenceNumber, new string[] {command, packetSent.ToString()});
178-
sequenceNumber = (sequenceNumber == 255) ? 0 : sequenceNumber + 1;
176+
packetQueue.Add(sequenceNumber, new string[] { command, packetSent.ToString() });
179177
}
178+
179+
socket.Send(packet);
180+
181+
sequenceNumber = (sequenceNumber == 255) ? 0 : sequenceNumber + 1;
180182
}
181183
catch
182184
{
@@ -202,11 +204,12 @@ private int SendCommandPacket(BattlEyeCommand command, string parameters = "")
202204

203205
byte[] packet = ConstructPacket(BattlEyePacketType.Command, sequenceNumber, Helpers.StringValueOf(command) + parameters);
204206

205-
socket.Send(packet);
206-
207207
packetSent = DateTime.Now;
208208

209209
packetQueue.Add(sequenceNumber, new string[] {Helpers.StringValueOf(command) + parameters, packetSent.ToString()});
210+
211+
socket.Send(packet);
212+
210213
sequenceNumber = (sequenceNumber == 255) ? 0 : sequenceNumber + 1;
211214
}
212215
catch
@@ -236,7 +239,10 @@ private byte[] ConstructPacket(BattlEyePacketType packetType, int sequenceNumber
236239
return new byte[] { };
237240
}
238241

239-
if (command != null) command = Encoding.GetEncoding(1252).GetString(Encoding.UTF8.GetBytes(command));
242+
if (packetType != BattlEyePacketType.Acknowledge)
243+
{
244+
if (command != null) command = Encoding.GetEncoding(1252).GetString(Encoding.UTF8.GetBytes(command));
245+
}
240246

241247
string count = Helpers.Bytes2String(new byte[] { (byte)sequenceNumber });
242248

@@ -319,7 +325,7 @@ private void Receive()
319325
DateTime date = DateTime.Parse(packetQueue[key][1]);
320326
int timeDiff = (int)(DateTime.Now - date).TotalSeconds;
321327

322-
if (timeDiff > 2)
328+
if (timeDiff > 5)
323329
{
324330
SendCommandPacket(value, false);
325331
packetQueue.Remove(key);

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.3.1
2+
* Fixed an issue where the (first) command would be sent twice
3+
* Fixed an issue where the library would lose connection after a long time, depending on server load (Thanks to EPM Cortez for finding the issue)
4+
15
v1.3
26
* Client now has DNS support
37
* BattlEyeLoginCredentials.Host changed from string to IPAddress

0 commit comments

Comments
 (0)