comprodls-sdk 2.73.0 → 2.74.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -923,7 +923,8 @@ var ERROR_TYPES = {
923
923
  "API_ERROR": "API_ERROR",
924
924
  "SDK_ERROR": "SDK_ERROR",
925
925
  "CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION",
926
- "UNEXPECTED_ERROR": "UNEXPECTED_ERROR"
926
+ "UNEXPECTED_ERROR": "UNEXPECTED_ERROR",
927
+ "POLLING_INITIATION": "POLLING_INITIATION"
927
928
  };
928
929
 
929
930
  var ERROR_CATEGORY = {
@@ -12825,8 +12826,7 @@ var keepaliveAgent = new Agent({
12825
12826
  /*********************************
12826
12827
  * Public Function definitions
12827
12828
  **********************************/
12828
- function pushX(accountId) {
12829
- this.accountId = accountId;
12829
+ function pushX() {
12830
12830
  var _pubnubClientWrapper = pubnubClientWrapper();
12831
12831
  return {
12832
12832
  "connect": _connect.bind(this, _pubnubClientWrapper),
@@ -12843,7 +12843,6 @@ function pushX(accountId) {
12843
12843
  **********************************/
12844
12844
 
12845
12845
  function _connect(pubnubCW, options) {
12846
- var self = this;
12847
12846
  var bpubnubV7 = true; // If pubnub v7 or higher in package.json, set it true
12848
12847
  if (bpubnubV7 && !options.userid) {
12849
12848
  var err = {};
@@ -12855,7 +12854,7 @@ function _connect(pubnubCW, options) {
12855
12854
  // Adding SSL flag
12856
12855
  return pubnubCW.setup({
12857
12856
  'userid': options.userid,
12858
- 'accountid': self.accountId,
12857
+ 'accountid': options.accountid,
12859
12858
  'pubnub': {
12860
12859
  'publishKey': options.publishKey,
12861
12860
  'subscribeKey': options.subscribeKey,
@@ -13111,7 +13110,7 @@ module.exports = function () {
13111
13110
  _eventEmitter.emit(subscribedChannel, message);
13112
13111
  };
13113
13112
 
13114
- var _translatePubnubStatus = function(status) {
13113
+ var _translatePubnubStatus = function(status, options) {
13115
13114
  var channels = [], error, successObj;
13116
13115
  switch (status.category) {
13117
13116
  case "PNConnectedCategory":
@@ -13172,13 +13171,25 @@ module.exports = function () {
13172
13171
  break;
13173
13172
  case "PNNetworkIssuesCategory":
13174
13173
  if(status.operation === 'PNSubscribeOperation') {
13175
- /**
13176
- * Handle network issue category status for 'subscription' opreration
13177
- * Start the events polling here.
13178
- *
13179
- * The wrapper supports multiple channels, but the APP currently uses a single channel only.
13180
- * Polling will also limited to a single channel.
13181
- */
13174
+ if(!options.accountId) {
13175
+ error = {
13176
+ message: "Missing mandatory parameters to initiate polling operation - accountId",
13177
+ status: status.statusCode,
13178
+ type: helpers.errors.ERROR_TYPES.POLLING_INITIATION,
13179
+ };
13180
+ error = new PUSHXError(helpers.errors.ERROR_CATEGORY.PUSHX, error);
13181
+ _eventEmitter.emit('pushx_status', error);
13182
+ break;
13183
+ }
13184
+ else {
13185
+ /**
13186
+ * Handle network issue category status for 'subscription' opreration
13187
+ * Start the events polling here.
13188
+ *
13189
+ * The wrapper supports multiple channels, but the APP currently uses a single channel only.
13190
+ * Polling will also limited to a single channel.
13191
+ */
13192
+ }
13182
13193
  }
13183
13194
  else {
13184
13195
  // Handle network issue category status for other operations like 'unsubscription'
@@ -13231,6 +13242,7 @@ module.exports = function () {
13231
13242
  var __setup = function (userOptions) {
13232
13243
  var pubnubConfig = userOptions.pubnub;
13233
13244
  pubnubConfig.uuid = userOptions.userid;
13245
+ var accountId = userOptions.accountid;
13234
13246
 
13235
13247
  if (!_pubnubClient && pubnubConfig) {
13236
13248
  _pubnubClient = new pubNub(pubnubConfig); //Connect with PubNub SDK
@@ -13249,7 +13261,8 @@ module.exports = function () {
13249
13261
  _translatePubnubMessage(data);
13250
13262
  },
13251
13263
  "status": function (status) {
13252
- _translatePubnubStatus(status);
13264
+ var statusOptions = { accountId: accountId };
13265
+ _translatePubnubStatus(status, statusOptions);
13253
13266
  }
13254
13267
  });
13255
13268
  }