Esempio n. 1
0
            internal UserNotificationsCallback(JobID jobID, CMsgClientUserNotifications msg)
            {
                if (jobID == null)
                {
                    throw new ArgumentNullException(nameof(jobID));
                }

                if (msg == null)
                {
                    throw new ArgumentNullException(nameof(msg));
                }

                JobID = jobID;

                // We might get null body here, and that means there are no notifications related to trading
                // TODO: Check if this workaround is still needed
                Notifications = new Dictionary <EUserNotification, uint> {
                    { EUserNotification.Trading, 0 }
                };

                if (msg.notifications == null)
                {
                    return;
                }

                foreach (CMsgClientUserNotifications.Notification notification in msg.notifications)
                {
                    EUserNotification type = (EUserNotification)notification.user_notification_type;

                    switch (type)
                    {
                    case EUserNotification.AccountAlerts:
                    case EUserNotification.Chat:
                    case EUserNotification.Comments:
                    case EUserNotification.GameTurns:
                    case EUserNotification.Gifts:
                    case EUserNotification.HelpRequestReplies:
                    case EUserNotification.Invites:
                    case EUserNotification.Items:
                    case EUserNotification.ModeratorMessages:
                    case EUserNotification.Trading:
                        break;

                    default:
                        ASF.ArchiLogger.LogGenericError(string.Format(CultureInfo.CurrentCulture, Strings.WarningUnknownValuePleaseReport, nameof(type), type));

                        break;
                    }

                    Notifications[type] = notification.count;
                }
            }
Esempio n. 2
0
            internal UserNotificationsCallback([JetBrains.Annotations.NotNull] JobID jobID, [JetBrains.Annotations.NotNull] CMsgClientUserNotifications msg)
            {
                if ((jobID == null) || (msg == null))
                {
                    throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg));
                }

                JobID = jobID;

                // We might get null body here, and that means there are no notifications related to trading
                Notifications = new Dictionary <EUserNotification, uint> {
                    { EUserNotification.Trading, 0 }
                };

                if (msg.notifications == null)
                {
                    return;
                }

                foreach (CMsgClientUserNotifications.Notification notification in msg.notifications)
                {
                    EUserNotification type = (EUserNotification)notification.user_notification_type;

                    switch (type)
                    {
                    case EUserNotification.AccountAlerts:
                    case EUserNotification.Chat:
                    case EUserNotification.Comments:
                    case EUserNotification.GameTurns:
                    case EUserNotification.Gifts:
                    case EUserNotification.HelpRequestReplies:
                    case EUserNotification.Invites:
                    case EUserNotification.Items:
                    case EUserNotification.ModeratorMessages:
                    case EUserNotification.Trading:
                        break;

                    default:
                        ASF.ArchiLogger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type));

                        continue;
                    }

                    Notifications[type] = notification.count;
                }
            }