internal ClientUserNotificationsCallback(JobID jobId, CMsgClientUserNotifications body) { JobID = jobId; Notifications = body.notifications.Select( n => new UserNotification((int)n.count, (NotificationType)n.user_notification_type) ).ToArray(); }
internal NotificationCallback(CMsgClientUserNotifications msg) { var list = msg.notifications .Select(n => new Notification(n)) .ToList(); this.Notifications = new ReadOnlyCollection <Notification>(list); }
private void HandleClientUserNotifications(IPacketMsg packetMsg) { var clientUserNotificationResponse = new ClientMsgProtobuf <CMsgClientUserNotifications>(packetMsg); CMsgClientUserNotifications result = clientUserNotificationResponse.Body; Client.PostCallback(new NotificationCallback(result)); }
/// <summary> /// First Constructor /// /// Pass a jobID so we can identify the callback if we are going to receive it as an answer from steam /// From the returned "_clientUserNotifications" we want to parse the notifications into the list of tradingnotifications /// </summary> /// <param name="_jobID"></param> /// <param name="_clientUserNotifications"></param> public NotificationCallback(JobID _jobID, CMsgClientUserNotifications _clientUserNotifications) { JobID = _jobID; if (_clientUserNotifications.notifications.Count > 0) { m_Notification = new List <ENotification>(_clientUserNotifications.notifications.Select(_notification => (ENotification)_notification.user_notification_type)); } }
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; } }
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; Notifications = new HashSet <ENotification>(); foreach (CMsgClientUserNotifications.Notification notification in msg.notifications) { Notifications.Add((ENotification)notification.user_notification_type); } }
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) { JobID = jobID; if (msg == null || msg.notifications == null) { return; } Notifications = new List <Notification>(msg.notifications.Count); foreach (var notification in msg.notifications) { Notifications.Add(new Notification((Notification.ENotificationType)notification.user_notification_type)); } }
internal UserNotificationsCallback([NotNull] JobID jobID, [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) { var 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: sc.Logger.LogGenericError(string.Format(Strings.WarningUnknownValuePleaseReport, nameof(type), type)); continue; } Notifications[type] = notification.count; } }
internal NotificationsCallback(JobID jobID, CMsgClientUserNotifications msg) { if ((jobID == null) || (msg == null)) { throw new ArgumentNullException(nameof(jobID) + " || " + nameof(msg)); } JobID = jobID; if (msg.notifications.Count == 0) { return; } Notifications = new HashSet <ENotification>(msg.notifications.Select(notification => (ENotification)notification.user_notification_type)); }