Skip to content

Commit fee0b87

Browse files
author
Devendra
committed
merging from develop
2 parents abd8405 + 578667f commit fee0b87

File tree

34 files changed

+2459
-4686
lines changed

34 files changed

+2459
-4686
lines changed

.travis.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
3+
node_js:
4+
- "0.12"
5+
- "0.10"
6+
- "iojs"
7+
8+
9+
before_install:
10+
npm install -g grunt-cli
11+
12+
install:
13+
cd node.js && npm install
14+
15+
script:
16+
grunt test

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ PubNub for JS Docs have been moved to: http://www.pubnub.com/docs/javascript/jav
55
### CDN Links
66

77
#### HTTP
8-
* http://cdn.pubnub.com/pubnub-3.7.8.min.js
9-
* http://cdn.pubnub.com/pubnub-3.7.8.js
8+
* http://cdn.pubnub.com/pubnub-3.7.9.min.js
9+
* http://cdn.pubnub.com/pubnub-3.7.9.js
1010

1111
#### HTTPS
12-
* https://cdn.pubnub.com/pubnub-3.7.8.min.js
13-
* https://cdn.pubnub.com/pubnub-3.7.8.js
12+
* https://cdn.pubnub.com/pubnub-3.7.9.min.js
13+
* https://cdn.pubnub.com/pubnub-3.7.9.js
1414

1515
# Please direct all Support Questions and Concerns to [email protected]

core/pubnub-common.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function PN_API(setup) {
304304
, PRESENCE_HB = validate_presence_heartbeat(
305305
setup['heartbeat'] || setup['pnexpires'] || 0, setup['error']
306306
)
307-
, PRESENCE_HB_INTERVAL = setup['heartbeat_interval'] || PRESENCE_HB - 3
307+
, PRESENCE_HB_INTERVAL = setup['heartbeat_interval'] || (PRESENCE_HB / 2) -1
308308
, PRESENCE_HB_RUNNING = false
309309
, NO_WAIT_FOR_PENDING = setup['no_wait_for_pending']
310310
, COMPATIBLE_35 = setup['compatible_3.5'] || false
@@ -321,6 +321,8 @@ function PN_API(setup) {
321321
, _poll_timer
322322
, _poll_timer2;
323323

324+
if (PRESENCE_HB === 2) PRESENCE_HB_INTERVAL = 1;
325+
324326
var crypto_obj = setup['crypto_obj'] ||
325327
{
326328
'encrypt' : function(a,key){ return a},
@@ -361,6 +363,10 @@ function PN_API(setup) {
361363
function validate_presence_heartbeat(heartbeat, cur_heartbeat, error) {
362364
var err = false;
363365

366+
if (typeof heartbeat === 'undefined') {
367+
return cur_heartbeat;
368+
}
369+
364370
if (typeof heartbeat === 'number') {
365371
if (heartbeat > PRESENCE_HB_THRESHOLD || heartbeat == 0)
366372
err = false;
@@ -647,19 +653,26 @@ function PN_API(setup) {
647653
'get_heartbeat' : function() {
648654
return PRESENCE_HB;
649655
},
650-
'set_heartbeat' : function(heartbeat) {
651-
PRESENCE_HB = validate_presence_heartbeat(heartbeat, PRESENCE_HB_INTERVAL, error);
652-
PRESENCE_HB_INTERVAL = (PRESENCE_HB - 3 >= 1)?PRESENCE_HB - 3:1;
656+
657+
'set_heartbeat' : function(heartbeat, heartbeat_interval) {
658+
PRESENCE_HB = validate_presence_heartbeat(heartbeat, PRESENCE_HB, error);
659+
PRESENCE_HB_INTERVAL = heartbeat_interval || (PRESENCE_HB / 2) - 1;
660+
if (PRESENCE_HB == 2) {
661+
PRESENCE_HB_INTERVAL = 1;
662+
}
653663
CONNECT();
654664
_presence_heartbeat();
655665
},
666+
656667
'get_heartbeat_interval' : function() {
657668
return PRESENCE_HB_INTERVAL;
658669
},
670+
659671
'set_heartbeat_interval' : function(heartbeat_interval) {
660672
PRESENCE_HB_INTERVAL = heartbeat_interval;
661673
_presence_heartbeat();
662674
},
675+
663676
'get_version' : function() {
664677
return SDK_VER;
665678
},
@@ -1109,6 +1122,7 @@ function PN_API(setup) {
11091122
, windowing = args['windowing'] || SUB_WINDOWING
11101123
, state = args['state']
11111124
, heartbeat = args['heartbeat'] || args['pnexpires']
1125+
, heartbeat_interval = args['heartbeat_interval']
11121126
, restore = args['restore'] || SUB_RESTORE;
11131127

11141128
// Restore Enabled?
@@ -1125,8 +1139,8 @@ function PN_API(setup) {
11251139
if (!callback) return error('Missing Callback');
11261140
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
11271141

1128-
if (heartbeat || heartbeat === 0) {
1129-
SELF['set_heartbeat'](heartbeat);
1142+
if (heartbeat || heartbeat === 0 || heartbeat_interval || heartbeat_interval === 0) {
1143+
SELF['set_heartbeat'](heartbeat, heartbeat_interval);
11301144
}
11311145

11321146
// Setup Channel(s)

modern/pubnub.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ function PN_API(setup) {
305305
, PRESENCE_HB = validate_presence_heartbeat(
306306
setup['heartbeat'] || setup['pnexpires'] || 0, setup['error']
307307
)
308-
, PRESENCE_HB_INTERVAL = setup['heartbeat_interval'] || PRESENCE_HB - 3
308+
, PRESENCE_HB_INTERVAL = setup['heartbeat_interval'] || (PRESENCE_HB / 2) -1
309309
, PRESENCE_HB_RUNNING = false
310310
, NO_WAIT_FOR_PENDING = setup['no_wait_for_pending']
311311
, COMPATIBLE_35 = setup['compatible_3.5'] || false
@@ -322,6 +322,8 @@ function PN_API(setup) {
322322
, _poll_timer
323323
, _poll_timer2;
324324

325+
if (PRESENCE_HB === 2) PRESENCE_HB_INTERVAL = 1;
326+
325327
var crypto_obj = setup['crypto_obj'] ||
326328
{
327329
'encrypt' : function(a,key){ return a},
@@ -362,6 +364,10 @@ function PN_API(setup) {
362364
function validate_presence_heartbeat(heartbeat, cur_heartbeat, error) {
363365
var err = false;
364366

367+
if (typeof heartbeat === 'undefined') {
368+
return cur_heartbeat;
369+
}
370+
365371
if (typeof heartbeat === 'number') {
366372
if (heartbeat > PRESENCE_HB_THRESHOLD || heartbeat == 0)
367373
err = false;
@@ -648,19 +654,26 @@ function PN_API(setup) {
648654
'get_heartbeat' : function() {
649655
return PRESENCE_HB;
650656
},
651-
'set_heartbeat' : function(heartbeat) {
652-
PRESENCE_HB = validate_presence_heartbeat(heartbeat, PRESENCE_HB_INTERVAL, error);
653-
PRESENCE_HB_INTERVAL = (PRESENCE_HB - 3 >= 1)?PRESENCE_HB - 3:1;
657+
658+
'set_heartbeat' : function(heartbeat, heartbeat_interval) {
659+
PRESENCE_HB = validate_presence_heartbeat(heartbeat, PRESENCE_HB, error);
660+
PRESENCE_HB_INTERVAL = heartbeat_interval || (PRESENCE_HB / 2) - 1;
661+
if (PRESENCE_HB == 2) {
662+
PRESENCE_HB_INTERVAL = 1;
663+
}
654664
CONNECT();
655665
_presence_heartbeat();
656666
},
667+
657668
'get_heartbeat_interval' : function() {
658669
return PRESENCE_HB_INTERVAL;
659670
},
671+
660672
'set_heartbeat_interval' : function(heartbeat_interval) {
661673
PRESENCE_HB_INTERVAL = heartbeat_interval;
662674
_presence_heartbeat();
663675
},
676+
664677
'get_version' : function() {
665678
return SDK_VER;
666679
},
@@ -1110,6 +1123,7 @@ function PN_API(setup) {
11101123
, windowing = args['windowing'] || SUB_WINDOWING
11111124
, state = args['state']
11121125
, heartbeat = args['heartbeat'] || args['pnexpires']
1126+
, heartbeat_interval = args['heartbeat_interval']
11131127
, restore = args['restore'] || SUB_RESTORE;
11141128

11151129
// Restore Enabled?
@@ -1126,8 +1140,8 @@ function PN_API(setup) {
11261140
if (!callback) return error('Missing Callback');
11271141
if (!SUBSCRIBE_KEY) return error('Missing Subscribe Key');
11281142

1129-
if (heartbeat || heartbeat === 0) {
1130-
SELF['set_heartbeat'](heartbeat);
1143+
if (heartbeat || heartbeat === 0 || heartbeat_interval || heartbeat_interval === 0) {
1144+
SELF['set_heartbeat'](heartbeat, heartbeat_interval);
11311145
}
11321146

11331147
// Setup Channel(s)

0 commit comments

Comments
 (0)