This commit is contained in:
JustArchi
2016-04-21 14:48:24 +02:00
parent 6b6d5429ad
commit 6622d3b147
5 changed files with 17 additions and 22 deletions

View File

@@ -67,7 +67,7 @@ namespace ArchiSteamFarm {
}
}
internal readonly List<Notification> Notifications;
internal readonly HashSet<Notification> Notifications;
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) {
JobID = jobID;
@@ -76,7 +76,7 @@ namespace ArchiSteamFarm {
return;
}
Notifications = new List<Notification>(msg.notifications.Count);
Notifications = new HashSet<Notification>();
foreach (var notification in msg.notifications) {
Notifications.Add(new Notification((Notification.ENotificationType) notification.user_notification_type));
}
@@ -90,7 +90,7 @@ namespace ArchiSteamFarm {
}
if (msg.count_new_items > 0) {
Notifications = new List<Notification>(1) {
Notifications = new HashSet<Notification>() {
new Notification(Notification.ENotificationType.Items)
};
}
@@ -99,7 +99,6 @@ namespace ArchiSteamFarm {
internal sealed class OfflineMessageCallback : CallbackMsg {
internal readonly uint OfflineMessages;
internal readonly List<uint> Users;
internal OfflineMessageCallback(JobID jobID, CMsgClientOfflineMessageNotification msg) {
JobID = jobID;
@@ -109,7 +108,6 @@ namespace ArchiSteamFarm {
}
OfflineMessages = msg.offline_messages;
Users = msg.friends_with_offline_messages;
}
}

View File

@@ -194,15 +194,13 @@ namespace ArchiSteamFarm {
}
internal async Task<bool> RefreshSessionIfNeeded() {
DateTime now = DateTime.Now;
if (now.Subtract(LastSessionRefreshCheck).TotalSeconds < MinSessionTTL) {
if (DateTime.Now.Subtract(LastSessionRefreshCheck).TotalSeconds < MinSessionTTL) {
return true;
}
await SessionSemaphore.WaitAsync().ConfigureAwait(false);
now = DateTime.Now;
if (now.Subtract(LastSessionRefreshCheck).TotalSeconds < MinSessionTTL) {
if (DateTime.Now.Subtract(LastSessionRefreshCheck).TotalSeconds < MinSessionTTL) {
SessionSemaphore.Release();
return true;
}
@@ -212,8 +210,7 @@ namespace ArchiSteamFarm {
bool? isLoggedIn = await IsLoggedIn().ConfigureAwait(false);
if (isLoggedIn.GetValueOrDefault(true)) {
result = true;
now = DateTime.Now;
LastSessionRefreshCheck = now;
LastSessionRefreshCheck = DateTime.Now;
} else {
Logging.LogGenericInfo("Refreshing our session!", Bot.BotName);
result = await Bot.RefreshSession().ConfigureAwait(false);

View File

@@ -1745,7 +1745,7 @@ namespace ArchiSteamFarm {
}
private void OnOfflineMessage(ArchiHandler.OfflineMessageCallback callback) {
if (callback == null) {
if (callback == null || callback.OfflineMessages == 0) {
return;
}

View File

@@ -79,8 +79,8 @@ namespace ArchiSteamFarm {
return;
}
uint result;
if (!uint.TryParse(value, out result)) {
ulong result;
if (!ulong.TryParse(value, out result)) {
return;
}
@@ -100,8 +100,8 @@ namespace ArchiSteamFarm {
return;
}
uint result;
if (!uint.TryParse(value, out result)) {
ulong result;
if (!ulong.TryParse(value, out result)) {
return;
}
@@ -127,8 +127,8 @@ namespace ArchiSteamFarm {
return;
}
uint result;
if (!uint.TryParse(value, out result)) {
ulong result;
if (!ulong.TryParse(value, out result)) {
return;
}
@@ -148,8 +148,8 @@ namespace ArchiSteamFarm {
return;
}
uint result;
if (!uint.TryParse(value, out result)) {
ulong result;
if (!ulong.TryParse(value, out result)) {
return;
}
@@ -337,7 +337,7 @@ namespace ArchiSteamFarm {
internal bool NewVersion { get; } = true;
[JsonProperty(PropertyName = "version", Required = Required.Always)]
internal int Version { get; } = 2;
internal byte Version { get; } = 2;
[JsonProperty(PropertyName = "me", Required = Required.Always)]
internal ItemList ItemsToGive { get; } = new ItemList();

View File

@@ -213,7 +213,7 @@ namespace ArchiSteamFarm {
return null;
}
if (request.StartsWith("https://") && Program.GlobalConfig.ForceHttp) {
if (request.StartsWith("https://", StringComparison.Ordinal) && Program.GlobalConfig.ForceHttp) {
return null;
}