Skip to content

Commit

Permalink
reorganized handleTransmissionError, removed resending cachedNotes
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Sep 27, 2011
1 parent 2097d6f commit 38c885c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/apn.js
Expand Up @@ -171,12 +171,18 @@ var Connection = function (optionArgs) {

var handleTransmissionError = function(data) {
// Need to check message that errors
// return failed notification to owner
// resend all following notifications
if(data[0] == 8) {
// return failed notification to owner
if (data[0] == 8) {
self.socket.end();

if (typeof options.errorCallback != 'function') {
self.cachedNotes = [];
return;
}

var currentCache = self.cachedNotes;
self.cachedNotes = [];
self.socket.end();

// This is an error condition
var errorCode = data[1];
var identifier = bytes2int(data.slice(2,6), 4);
Expand All @@ -191,12 +197,6 @@ var Connection = function (optionArgs) {
if(typeof options.errorCallback == 'function') {
options.errorCallback(errorCode, note);
}
while(currentCache.length) {
note = currentCache.shift();
process.nextTick(function() {
self.sendNotification(note);
});
}
}
}
}
Expand Down

0 comments on commit 38c885c

Please sign in to comment.