Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes #9, Addresses an issue if the socket disconnects with queued no…

…tifications it would be reinitialised before its teardown is completed leaving the system in an undefined state.
  • Loading branch information...
commit 052eabf6916a5e546a0fab79007757c0a9b0bd18 1 parent 623a5f9
@argon authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/apn.js
View
13 lib/apn.js
@@ -46,8 +46,15 @@ var Connection = function (optionArgs) {
}
var startSocket = function () {
- self.socket = tls.connect(options['port'], options['gateway'], socketOptions);
- self.socket.pair.on('secure', function () { if(!self.socket.authorized) { throw self.socket.authorizationError } while(offlineCache.length) { self.socket.write(offlineCache.shift()); } });
+ self.socket = tls.connect(options['port'], options['gateway'], socketOptions,
+ callback = function() {
+ if(!self.socket.authorized) {
+ throw self.socket.authorizationError
+ }
+ while(offlineCache.length) {
+ self.socket.write(offlineCache.shift());
+ }
+ });
self.socket.on('data', function(data) { handleTransmissionError(data); });
self.socket.on('error', function(data) {self.socket.removeAllListeners(); self.socket = undefined; });
self.socket.once('end', function () { });
@@ -156,7 +163,9 @@ var Connection = function (optionArgs) {
}
while(currentCache.length) {
note = currentCache.shift();
+ process.nextTick(function() {
self.sendNotification(note);
+ });
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.