void HandleStatus(SendNotificationCallbackDelegate callback, WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { if (callback != null) { callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true }); } } else if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { if (callback != null) { callback(this, new SendNotificationResult(notification)); } } else { if (callback != null) { callback(this, new SendNotificationResult(status.Notification, false, new WindowsPhoneNotificationSendFailureException(status))); } } Interlocked.Decrement(ref waitCounter); }
void HandleStatus(SendNotificationCallbackDelegate callback, WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (callback == null) { return; } if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true, OldSubscriptionId = notification != null ? notification.EndPointUrl : null, SubscriptionExpiryUtc = DateTime.UtcNow }); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { callback(this, new SendNotificationResult(notification)); return; } callback(this, new SendNotificationResult(status.Notification, false, new WindowsPhoneNotificationSendFailureException(status))); }
void HandleStatus(WindowsPhoneMessageStatus status) { if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { Events.RaiseNotificationSent(status.Notification); return; } Events.RaiseNotificationSendFailure(status.Notification, new WindowsPhoneNotificationSendFailureException(status)); }
WindowsPhoneMessageStatus ParseStatus(HttpWebResponse resp, WindowsPhoneNotification notification) { var result = new WindowsPhoneMessageStatus(); result.Notification = notification; result.HttpStatus = HttpStatusCode.ServiceUnavailable; var wpStatus = string.Empty; var wpChannelStatus = string.Empty; var wpDeviceConnectionStatus = string.Empty; var messageID = string.Empty; if (resp != null) { result.HttpStatus = resp.StatusCode; wpStatus = resp.Headers["X-NotificationStatus"]; wpChannelStatus = resp.Headers["X-SubscriptionStatus"]; wpDeviceConnectionStatus = resp.Headers["X-DeviceConnectionStatus"]; messageID = resp.Headers["X-MessageID"]; } Guid msgGuid = Guid.NewGuid(); if (Guid.TryParse(messageID, out msgGuid)) { result.MessageID = msgGuid; } WPDeviceConnectionStatus devConStatus = WPDeviceConnectionStatus.NotAvailable; Enum.TryParse <WPDeviceConnectionStatus>(wpDeviceConnectionStatus, true, out devConStatus); result.DeviceConnectionStatus = devConStatus; WPNotificationStatus notStatus = WPNotificationStatus.NotAvailable; Enum.TryParse <WPNotificationStatus>(wpStatus, true, out notStatus); result.NotificationStatus = notStatus; WPSubscriptionStatus subStatus = WPSubscriptionStatus.NotAvailable; Enum.TryParse <WPSubscriptionStatus>(wpChannelStatus, true, out subStatus); result.SubscriptionStatus = subStatus; return(result); }
void HandleStatus(WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { Events.RaiseDeviceSubscriptionExpired(PlatformType.WindowsPhone, notification.EndPointUrl, notification); Events.RaiseNotificationSendFailure(notification, new WindowsPhoneNotificationSendFailureException(status)); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { Events.RaiseNotificationSent(status.Notification); return; } Events.RaiseNotificationSendFailure(status.Notification, new WindowsPhoneNotificationSendFailureException(status)); }
WindowsPhoneMessageStatus ParseStatus(HttpWebResponse resp, WindowsPhoneNotification notification) { var result = new WindowsPhoneMessageStatus(); result.Notification = notification; result.HttpStatus = resp.StatusCode; var wpStatus = resp.Headers["X-NotificationStatus"]; var wpChannelStatus = resp.Headers["X-SubscriptionStatus"]; var wpDeviceConnectionStatus = resp.Headers["X-DeviceConnectionStatus"]; var messageID = resp.Headers["X-MessageID"]; Guid msgGuid = Guid.NewGuid(); if (Guid.TryParse(messageID, out msgGuid)) { result.MessageID = msgGuid; } WPDeviceConnectionStatus devConStatus = WPDeviceConnectionStatus.InActive; Enum.TryParse <WPDeviceConnectionStatus>(wpDeviceConnectionStatus, out devConStatus); result.DeviceConnectionStatus = devConStatus; WPNotificationStatus notStatus = WPNotificationStatus.Dropped; Enum.TryParse <WPNotificationStatus>(wpStatus, out notStatus); result.NotificationStatus = notStatus; WPSubscriptionStatus subStatus = WPSubscriptionStatus.Expired; Enum.TryParse <WPSubscriptionStatus>(wpChannelStatus, out subStatus); result.SubscriptionStatus = subStatus; return(result); }
WindowsPhoneMessageStatus ParseStatus(HttpWebResponse resp, WindowsPhoneNotification notification) { var result = new WindowsPhoneMessageStatus(); result.Notification = notification; result.HttpStatus = resp.StatusCode; var wpStatus = resp.Headers["X-NotificationStatus"]; var wpChannelStatus = resp.Headers["X-SubscriptionStatus"]; var wpDeviceConnectionStatus = resp.Headers["X-DeviceConnectionStatus"]; var messageID = resp.Headers["X-MessageID"]; Guid msgGuid = Guid.NewGuid(); if (Guid.TryParse(messageID, out msgGuid)) result.MessageID = msgGuid; WPDeviceConnectionStatus devConStatus = WPDeviceConnectionStatus.InActive; Enum.TryParse<WPDeviceConnectionStatus>(wpDeviceConnectionStatus, out devConStatus); result.DeviceConnectionStatus = devConStatus; WPNotificationStatus notStatus = WPNotificationStatus.Dropped; Enum.TryParse<WPNotificationStatus>(wpStatus, out notStatus); result.NotificationStatus = notStatus; WPSubscriptionStatus subStatus = WPSubscriptionStatus.Expired; Enum.TryParse<WPSubscriptionStatus>(wpChannelStatus, out subStatus); result.SubscriptionStatus = subStatus; return result; }
WindowsPhoneMessageStatus ParseStatus(HttpWebResponse resp, WindowsPhoneNotification notification) { var result = new WindowsPhoneMessageStatus(); result.Notification = notification; result.HttpStatus = HttpStatusCode.ServiceUnavailable; var wpStatus = string.Empty; var wpChannelStatus = string.Empty; var wpDeviceConnectionStatus = string.Empty; var messageID = string.Empty; if (resp != null) { result.HttpStatus = resp.StatusCode; wpStatus = resp.Headers["X-NotificationStatus"]; wpChannelStatus = resp.Headers["X-SubscriptionStatus"]; wpDeviceConnectionStatus = resp.Headers["X-DeviceConnectionStatus"]; messageID = resp.Headers["X-MessageID"]; } Guid msgGuid = Guid.NewGuid(); if (Guid.TryParse(messageID, out msgGuid)) result.MessageID = msgGuid; WPDeviceConnectionStatus devConStatus = WPDeviceConnectionStatus.NotAvailable; Enum.TryParse<WPDeviceConnectionStatus>(wpDeviceConnectionStatus, true, out devConStatus); result.DeviceConnectionStatus = devConStatus; WPNotificationStatus notStatus = WPNotificationStatus.NotAvailable; Enum.TryParse<WPNotificationStatus>(wpStatus, true, out notStatus); result.NotificationStatus = notStatus; WPSubscriptionStatus subStatus = WPSubscriptionStatus.NotAvailable; Enum.TryParse<WPSubscriptionStatus>(wpChannelStatus, true, out subStatus); result.SubscriptionStatus = subStatus; return result; }
void HandleStatus(SendNotificationCallbackDelegate callback, WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (callback == null) return; if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true, OldSubscriptionId = notification != null ? notification.EndPointUrl : null, SubscriptionExpiryUtc = DateTime.UtcNow }); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { callback(this, new SendNotificationResult(notification)); return; } callback(this, new SendNotificationResult(status.Notification, false, new WindowsPhoneNotificationSendFailureException(status))); }
public WindowsPhoneNotificationSendFailureException(WindowsPhoneMessageStatus msgStatus) : base() { this.MessageStatus = msgStatus; }
void HandleStatus(SendNotificationCallbackDelegate callback, WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { if (callback != null) callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true }); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { if (callback != null) callback(this, new SendNotificationResult(notification)); return; } if (callback != null) callback(this, new SendNotificationResult(status.Notification, false, new WindowsPhoneNotificationSendFailureException(status))); }
public WindowsPhoneNotificationSendFailureException(WindowsPhoneMessageStatus msgStatus, string message = "") : base(message) { this.MessageStatus = msgStatus; }
void HandleStatus(SendNotificationCallbackDelegate callback, WindowsPhoneMessageStatus status, WindowsPhoneNotification notification = null) { if (callback == null) { return; } if (status.SubscriptionStatus == WPSubscriptionStatus.Expired) { callback(this, new SendNotificationResult(notification, false, new Exception("Device Subscription Expired")) { IsSubscriptionExpired = true, OldSubscriptionId = notification != null ? notification.EndPointUrl : null, SubscriptionExpiryUtc = DateTime.UtcNow }); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Received) { callback(this, new SendNotificationResult(notification)); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Suppressed) { callback(this, new SendNotificationResult(notification, suppressed: true)); return; } if (status.HttpStatus == HttpStatusCode.OK && status.NotificationStatus == WPNotificationStatus.Dropped) { callback(this, new SendNotificationResult(notification)); return; } // Disconnected Device: he cloud service should continue sending notifications as usual even though those notifications // are dropped because when the device returns to Connected status this ensures the notification flow continues to the device. if (status.HttpStatus == HttpStatusCode.PreconditionFailed && status.NotificationStatus == WPNotificationStatus.Dropped) { callback(this, new SendNotificationResult(notification, suppressed: true)); return; } // This error occurs when an unauthenticated cloud service has reached the per-day throttling limit for a subscription, // or when a cloud service (authenticated or unauthenticated) has sent too many notifications per second. if (status.HttpStatus == HttpStatusCode.NotAcceptable && status.NotificationStatus == WPNotificationStatus.Dropped) { callback(this, new SendNotificationResult(notification, error: new WindowsPhoneNotificationSendFailureException(status, "This error occurs when an unauthenticated cloud service has reached the per-day throttling limit for a subscription, or when a cloud service (authenticated or unauthenticated) has sent too many notifications per second. "))); return; } callback(this, new SendNotificationResult(status.Notification, false, new WindowsPhoneNotificationSendFailureException(status))); }