Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ node_modules/
.vs/

settings.json
/PushSharp.1.0.6.nupkg
/PushSharp.4.0.10.1.nupkg
/PushSharp.Core.1.0.6340.27706.nupkg
/PushSharp.Apple.1.0.6340.27706.nupkg
Binary file added PushSharp.4.0.11.nupkg
Binary file not shown.
25 changes: 20 additions & 5 deletions PushSharp.Apple/ApnsConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,13 @@ async Task SendBatch ()
// Let's store the batch items to send internally
var toSend = new List<CompletableApnsNotification> ();

while (notifications.Count > 0 && toSend.Count < Configuration.InternalBatchSize) {
var n = notifications.Dequeue ();
toSend.Add (n);
lock (notificationBatchQueueLock)
{
while (notifications.Count > 0 && toSend.Count < Configuration.InternalBatchSize)
{
var n = notifications.Dequeue ();
toSend.Add(n);
}
}


Expand Down Expand Up @@ -154,13 +158,24 @@ async Task SendBatch ()
}

foreach (var n in toSend)
sent.Add (new SentNotification (n));
sent.Add(new SentNotification(n));
}

} catch (Exception ex) {
Log.Error ("APNS-CLIENT[{0}]: Send Batch Error: Batch ID={1}, Error={2}", id, batchId, ex);
var errorNotificationToSend = new List<CompletableApnsNotification>();

foreach (var n in toSend)
n.CompleteFailed (new ApnsNotificationException (ApnsNotificationErrorStatusCode.ConnectionError, n.Notification, ex));
{
if (!n.Notification.IsDeviceRegistrationIdValid())
errorNotificationToSend.Add(n);
else
notifications.Enqueue(n);
}

foreach (var n in errorNotificationToSend)
n.CompleteFailed(new ApnsNotificationException(ApnsNotificationErrorStatusCode.ConnectionError, n.Notification, ex));

}

Log.Info ("APNS-Client[{0}]: Sent Batch, waiting for possible response...", id);
Expand Down