mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 22:20:52 +00:00
Further HeartBeat() enhancements
This is another great idea I thought about - ArchiHandler already receives all packets from Steam Network, so why bother checking if steam client is still alive if we can make use of the time last message arrived, and send request only when needed. Extra points for performance benefits for accounts receiving lots of packets, so mainly primary ones with lots of friends/groups
This commit is contained in:
@@ -37,6 +37,8 @@ namespace ArchiSteamFarm {
|
||||
internal sealed class ArchiHandler : ClientMsgHandler {
|
||||
internal const byte MaxGamesPlayedConcurrently = 32; // This is limit introduced by Steam Network
|
||||
|
||||
internal DateTime LastPacketReceived { get; private set; } = DateTime.MinValue;
|
||||
|
||||
private readonly ArchiLogger ArchiLogger;
|
||||
|
||||
internal ArchiHandler(ArchiLogger archiLogger) {
|
||||
@@ -53,6 +55,8 @@ namespace ArchiSteamFarm {
|
||||
return;
|
||||
}
|
||||
|
||||
LastPacketReceived = DateTime.Now;
|
||||
|
||||
switch (packetMsg.MsgType) {
|
||||
case EMsg.ClientFSOfflineMessageNotification:
|
||||
HandleFSOfflineMessageNotification(packetMsg);
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace ArchiSteamFarm {
|
||||
private const uint LoginID = GlobalConfig.DefaultWCFPort; // This must be the same for all ASF bots and all ASF processes
|
||||
private const ushort MaxSteamMessageLength = 2048;
|
||||
private const byte MaxTwoFactorCodeFailures = 3;
|
||||
private const byte MinHeartBeatTTL = GlobalConfig.DefaultConnectionTimeout; // Assume client is responsive for at least that amount of seconds
|
||||
|
||||
internal static readonly ConcurrentDictionary<string, Bot> Bots = new ConcurrentDictionary<string, Bot>();
|
||||
|
||||
@@ -756,7 +757,10 @@ namespace ArchiSteamFarm {
|
||||
}
|
||||
|
||||
try {
|
||||
await SteamApps.PICSGetProductInfo(0, null);
|
||||
if (DateTime.Now.Subtract(ArchiHandler.LastPacketReceived).TotalSeconds > MinHeartBeatTTL) {
|
||||
await SteamApps.PICSGetProductInfo(0, null);
|
||||
}
|
||||
|
||||
HeartBeatFailures = 0;
|
||||
Statistics?.OnHeartBeat().Forget();
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user