Permalink
Browse files

Tidied up debug module loading. Fixed some typos in feedback.js, than…

…ks to AsadR
  • Loading branch information...
1 parent 47aa238 commit 46b324759e3cd16bbec2c265501637fdc848f221 @argon argon committed Aug 2, 2012
Showing with 34 additions and 17 deletions.
  1. +14 −2 README.md
  2. +9 −6 lib/connection.js
  3. +11 −9 lib/feedback.js
View
@@ -41,7 +41,7 @@ Create a new connection to the gateway server using a dictionary of options. The
key: 'key.pem', /* Key file path */
keyData: null, /* String or Buffer containing key data, as certData */
passphrase: null, /* A passphrase for the Key file */
- ca: null /* String or Buffer of CA data to use for the TLS connection */
+ ca: null, /* String or Buffer of CA data to use for the TLS connection */
gateway: 'gateway.push.apple.com',/* gateway address */
port: 2195, /* gateway port */
enhanced: true, /* enable enhanced format */
@@ -131,11 +131,17 @@ Now, in the directory containing cert.cer and key.p12 execute the following comm
If you are using a development certificate you may wish to name them differently to enable fast switching between development and production. The filenames are configurable within the module options, so feel free to name them something more appropriate.
+## Debugging
+
+If you experience difficulties sending notifications or using the feedback service you can enable debug messages within the library by running your application with `DEBUG=apn` or `DEBUG=apnfb`.
+
+You will need the `debug` module which can be installed with `npm install debug`.
+
## Credits
Written and maintained by [Andrew Naylor][andrewnaylor].
-Contributors: [Ian Babrou][bobrik], [dgthistle][dgthistle], [Keith Larsen][keithnlarsen], [Mike P][mypark], [Greg Bergé][neoziro]
+Contributors: [Ian Babrou][bobrik], [dgthistle][dgthistle], [Keith Larsen][keithnlarsen], [Mike P][mypark], [Greg Bergé][neoziro], [Asad ur Rehman][AsadR]
## License
@@ -166,10 +172,16 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
[keithnlarsen]: https://github.com/keithnlarsen
[mypark]: https://github.com/mypark
[neoziro]: https://github.com/neoziro
+[AsadR]: https://github.com/AsadR
[q]: https://github.com/kriskowal/q
## Changelog
+1.2.4:
+
+* Fixed some typos in the feedback methods
+* Added some debug messages available during development
+
1.2.3:
* Added some more error handling to the connection methods.
View
@@ -4,12 +4,15 @@ var fs = require('fs');
var q = require('q');
var tls = require('tls');
var util = require('./util');
-try {
- var debug = require('debug')('apn');
-}
-catch (e) {
- console.log("Notice: Unable to load 'debug' module", e);
- var debug = function() {};
+var debug = function() {};
+if(process.env.DEBUG) {
+ try {
+ debug = require('debug')('apn');
+ }
+ catch (e) {
+ console.log("Notice: 'debug' module is not available. This should be installed with `npm install debug` to enable debug messages", e);
+ debug = function() {};
+ }
}
/**
View
@@ -5,14 +5,16 @@ var fs = require('fs');
var q = require('q');
var tls = require('tls');
var util = require('./util');
-try {
- var debug = require('debug')('apnfb');
-}
-catch (e) {
- console.log("Notice: Unable to load 'debug' module", e);
- var debug = function() {};
+var debug = function() {};
+if(process.env.DEBUG) {
+ try {
+ debug = require('debug')('apnfb');
+ }
+ catch (e) {
+ console.log("Notice: 'debug' module is not available. This should be installed with `npm install debug` to enable debug messages", e);
+ debug = function() {};
+ }
}
-
/**
* Create a new connection to the APN Feedback.
* @constructor
@@ -136,7 +138,7 @@ Feedback.prototype.connect = function () {
this.socket = tls.connect(
this.options['port'],
- this.options['gateway'],
+ this.options['address'],
socketOptions,
function () {
if (!this.socket.authorized) {
@@ -148,7 +150,7 @@ Feedback.prototype.connect = function () {
this.deferredConnection.resolve();
}.bind(this));
- this.receiveBuffer = new Buffer(0);
+ this.readBuffer = new Buffer(0);
this.socket.on('data', this.receive.bind(this));
this.socket.on("error", this.destroyConnection.bind(this));
this.socket.once('close', this.resetConnection.bind(this));

0 comments on commit 46b3247

Please sign in to comment.