Skip to content

Commit f0d288b

Browse files
author
Devendra
committed
adding pnexpires and metadata arguments to subscribe method
1 parent 4dd1fbb commit f0d288b

23 files changed

Lines changed: 462 additions & 325 deletions

File tree

core/pubnub-common.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ function build_url( url_components, url_params ) {
4848
if (!url_params) return url;
4949

5050
each( url_params, function( key, value ) {
51+
var value_str = (typeof value == 'object')?JSON['stringify'](value):value;
5152
(typeof value != 'undefined' &&
52-
value != null && encode(value).length > 0
53-
) && params.push(key + "=" + encode(value));
53+
value != null && encode(value_str).length > 0
54+
) && params.push(key + "=" + encode(value_str));
5455
} );
5556

5657
url += "?" + params.join(PARAMSBIT);
@@ -578,6 +579,8 @@ function PN_API(setup) {
578579
, timetoken = args['timetoken'] || 0
579580
, sub_timeout = args['timeout'] || SUB_TIMEOUT
580581
, windowing = args['windowing'] || SUB_WINDOWING
582+
, metadata = args['metadata']
583+
, pnexpires = args['pnexpires']
581584
, restore = args['restore'];
582585

583586
// Restore Enabled?
@@ -680,6 +683,11 @@ function PN_API(setup) {
680683

681684
// Connect to PubNub Subscribe Servers
682685
_reset_offline();
686+
687+
var data = { 'uuid' : UUID, 'auth' : auth_key };
688+
if (metadata) data['metadata'] = metadata;
689+
if (pnexpires) data['pnexpires'] = pnexpires;
690+
683691
SUB_RECEIVER = xdr({
684692
timeout : sub_timeout,
685693
callback : jsonp,
@@ -688,7 +696,7 @@ function PN_API(setup) {
688696
SUB_RECEIVER = null;
689697
SELF['time'](_test_connection);
690698
},
691-
data : { 'uuid' : UUID, 'auth' : auth_key },
699+
data : data,
692700
url : [
693701
SUB_ORIGIN, 'subscribe',
694702
SUBSCRIBE_KEY, encode(channels),

modern/pubnub.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ function build_url( url_components, url_params ) {
4949
if (!url_params) return url;
5050

5151
each( url_params, function( key, value ) {
52+
var value_str = (typeof value == 'object')?JSON['stringify'](value):value;
5253
(typeof value != 'undefined' &&
53-
value != null && encode(value).length > 0
54-
) && params.push(key + "=" + encode(value));
54+
value != null && encode(value_str).length > 0
55+
) && params.push(key + "=" + encode(value_str));
5556
} );
5657

5758
url += "?" + params.join(PARAMSBIT);
@@ -579,6 +580,8 @@ function PN_API(setup) {
579580
, timetoken = args['timetoken'] || 0
580581
, sub_timeout = args['timeout'] || SUB_TIMEOUT
581582
, windowing = args['windowing'] || SUB_WINDOWING
583+
, metadata = args['metadata']
584+
, pnexpires = args['pnexpires']
582585
, restore = args['restore'];
583586

584587
// Restore Enabled?
@@ -681,6 +684,11 @@ function PN_API(setup) {
681684

682685
// Connect to PubNub Subscribe Servers
683686
_reset_offline();
687+
688+
var data = { 'uuid' : UUID, 'auth' : auth_key };
689+
if (metadata) data['metadata'] = metadata;
690+
if (pnexpires) data['pnexpires'] = pnexpires;
691+
684692
SUB_RECEIVER = xdr({
685693
timeout : sub_timeout,
686694
callback : jsonp,
@@ -689,7 +697,7 @@ function PN_API(setup) {
689697
SUB_RECEIVER = null;
690698
SELF['time'](_test_connection);
691699
},
692-
data : { 'uuid' : UUID, 'auth' : auth_key },
700+
data : data,
693701
url : [
694702
SUB_ORIGIN, 'subscribe',
695703
SUBSCRIBE_KEY, encode(channels),

modern/pubnub.min.js

Lines changed: 36 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node.js/pubnub.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ function build_url( url_components, url_params ) {
4949
if (!url_params) return url;
5050

5151
each( url_params, function( key, value ) {
52+
var value_str = (typeof value == 'object')?JSON['stringify'](value):value;
5253
(typeof value != 'undefined' &&
53-
value != null && encode(value).length > 0
54-
) && params.push(key + "=" + encode(value));
54+
value != null && encode(value_str).length > 0
55+
) && params.push(key + "=" + encode(value_str));
5556
} );
5657

5758
url += "?" + params.join(PARAMSBIT);
@@ -579,6 +580,8 @@ function PN_API(setup) {
579580
, timetoken = args['timetoken'] || 0
580581
, sub_timeout = args['timeout'] || SUB_TIMEOUT
581582
, windowing = args['windowing'] || SUB_WINDOWING
583+
, metadata = args['metadata']
584+
, pnexpires = args['pnexpires']
582585
, restore = args['restore'];
583586

584587
// Restore Enabled?
@@ -681,6 +684,11 @@ function PN_API(setup) {
681684

682685
// Connect to PubNub Subscribe Servers
683686
_reset_offline();
687+
688+
var data = { 'uuid' : UUID, 'auth' : auth_key };
689+
if (metadata) data['metadata'] = metadata;
690+
if (pnexpires) data['pnexpires'] = pnexpires;
691+
684692
SUB_RECEIVER = xdr({
685693
timeout : sub_timeout,
686694
callback : jsonp,
@@ -689,7 +697,7 @@ function PN_API(setup) {
689697
SUB_RECEIVER = null;
690698
SELF['time'](_test_connection);
691699
},
692-
data : { 'uuid' : UUID, 'auth' : auth_key },
700+
data : data,
693701
url : [
694702
SUB_ORIGIN, 'subscribe',
695703
SUBSCRIBE_KEY, encode(channels),

phonegap/pubnub.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ function build_url( url_components, url_params ) {
4949
if (!url_params) return url;
5050

5151
each( url_params, function( key, value ) {
52+
var value_str = (typeof value == 'object')?JSON['stringify'](value):value;
5253
(typeof value != 'undefined' &&
53-
value != null && encode(value).length > 0
54-
) && params.push(key + "=" + encode(value));
54+
value != null && encode(value_str).length > 0
55+
) && params.push(key + "=" + encode(value_str));
5556
} );
5657

5758
url += "?" + params.join(PARAMSBIT);
@@ -579,6 +580,8 @@ function PN_API(setup) {
579580
, timetoken = args['timetoken'] || 0
580581
, sub_timeout = args['timeout'] || SUB_TIMEOUT
581582
, windowing = args['windowing'] || SUB_WINDOWING
583+
, metadata = args['metadata']
584+
, pnexpires = args['pnexpires']
582585
, restore = args['restore'];
583586

584587
// Restore Enabled?
@@ -681,6 +684,11 @@ function PN_API(setup) {
681684

682685
// Connect to PubNub Subscribe Servers
683686
_reset_offline();
687+
688+
var data = { 'uuid' : UUID, 'auth' : auth_key };
689+
if (metadata) data['metadata'] = metadata;
690+
if (pnexpires) data['pnexpires'] = pnexpires;
691+
684692
SUB_RECEIVER = xdr({
685693
timeout : sub_timeout,
686694
callback : jsonp,
@@ -689,7 +697,7 @@ function PN_API(setup) {
689697
SUB_RECEIVER = null;
690698
SELF['time'](_test_connection);
691699
},
692-
data : { 'uuid' : UUID, 'auth' : auth_key },
700+
data : data,
693701
url : [
694702
SUB_ORIGIN, 'subscribe',
695703
SUBSCRIBE_KEY, encode(channels),

0 commit comments

Comments
 (0)