Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated Node.JS PubNub API with latest Node.JS interface and better S…

…SL support.
  • Loading branch information...
commit 54ac8756577ac7d71c7e1d0adc4031e141bb7339 1 parent 6b58cbb
Stephen L. Blum stephenlb authored
Showing with 23 additions and 24 deletions.
  1. +1 −1  nodejs/package.json
  2. +22 −23 nodejs/pubnub.js
2  nodejs/package.json
View
@@ -1,7 +1,7 @@
{
"name": "pubnub",
"preferGlobal": false,
- "version": "3.1.6",
+ "version": "3.1.7",
"author": "Pubnub <stephen@pubnub.com>",
"description": "Publish & Subscribe Real-time Messaging with PubNub",
"contributors": [
45 nodejs/pubnub.js
View
@@ -105,33 +105,32 @@ function xdr( setup ) {
, origin = setup.origin
, ssl = setup.ssl
, failed = 0
+ , body = ''
, fail = function(e) {
if (failed) return;
failed = 1;
(setup.fail||function(){})(e);
- }, body = ''
- , client = http.createClient( 80, origin, ssl )
- , request = client.request( 'GET', url, { 'host': origin });
-
- request.end();
- request.on( 'error', fail );
- request.on( 'response', function (response) {
- response.setEncoding('utf8');
-
- response.on( 'error', fail );
- response.on( 'data', function (chunk) {
- if (chunk) body += chunk;
- } );
- response.on( 'end', function () {
- try {
- if (body) return success(JSON.parse(body));
- else fail();
- }
- catch(e) {
- fail();
- }
- } );
- } );
+ };
+
+ try {
+ http.get( {

In reference to #70

I hacked it locally to something like below and it now delivers messages when ssl is true.

try {
    var _http = ssl ? require( 'https' ) : http;
    _http.get({
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ host : origin,
+ port : ssl ? 443 : 80,
+ path : url
+ }, function(response) {
+ response.setEncoding('utf8');
+ response.on( 'error', fail );
+ response.on( 'data', function (chunk) {
+ if (chunk) body += chunk;
+ } );
+ response.on( 'end', function () {
+ try {
+ if (body) return success(JSON.parse(body));
+ else fail();
+ } catch(e) { fail(); }
+ } );
+ }).on( 'error', fail );
+ } catch(e) { fail(); }
}
Tristan Slominski

In reference to #70

I hacked it locally to something like below and it now delivers messages when ssl is true.

try {
    var _http = ssl ? require( 'https' ) : http;
    _http.get({
Please sign in to comment.
Something went wrong with that request. Please try again.