5436
5436
return base.PubNubFile;
5437
5437
},
5438
5438
get version() {
5439
- return '10.0 .0';
5439
+ return '10.1 .0';
5440
5440
},
5441
5441
getVersion() {
5442
5442
return this.version;
8923
8923
this.engine.transition(joined(this.channels.slice(0), this.groups.slice(0)));
8924
8924
}
8925
8925
leave({ channels, groups }) {
8926
+ // Update internal channel tracking to prevent stale heartbeat requests
8927
+ if (channels)
8928
+ this.channels = this.channels.filter((channel) => !channels.includes(channel));
8929
+ if (groups)
8930
+ this.groups = this.groups.filter((group) => !groups.includes(group));
8926
8931
if (this.dependencies.presenceState) {
8927
8932
channels === null || channels === void 0 ? void 0 : channels.forEach((c) => delete this.dependencies.presenceState[c]);
8928
8933
groups === null || groups === void 0 ? void 0 : groups.forEach((g) => delete this.dependencies.presenceState[g]);
8929
8934
}
8930
8935
this.engine.transition(left(channels !== null && channels !== void 0 ? channels : [], groups !== null && groups !== void 0 ? groups : []));
8931
8936
}
8932
8937
leaveAll(isOffline = false) {
8938
+ // Clear presence state for all current channels and groups
8939
+ if (this.dependencies.presenceState) {
8940
+ this.channels.forEach((c) => delete this.dependencies.presenceState[c]);
8941
+ this.groups.forEach((g) => delete this.dependencies.presenceState[g]);
8942
+ }
8943
+ // Reset internal channel and group tracking
8944
+ this.channels = [];
8945
+ this.groups = [];
8933
8946
this.engine.transition(leftAll(isOffline));
8934
8947
}
8935
8948
reconnect() {
@@ -11432,19 +11445,18 @@
11432
11445
*/
11433
11446
class HereNowRequest extends AbstractRequest {
11434
11447
constructor(parameters) {
11435
- var _a, _b, _c, _d ;
11436
- var _e, _f, _g, _h ;
11448
+ var _a, _b, _c;
11449
+ var _d, _e, _f ;
11437
11450
super();
11438
11451
this.parameters = parameters;
11439
11452
// Apply defaults.
11440
- (_a = (_e = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_e .queryParameters = {});
11441
- (_b = (_f = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_f .includeUUIDs = INCLUDE_UUID$1);
11442
- (_c = (_g = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_g .includeState = INCLUDE_STATE);
11453
+ (_a = (_d = this.parameters).queryParameters) !== null && _a !== void 0 ? _a : (_d .queryParameters = {});
11454
+ (_b = (_e = this.parameters).includeUUIDs) !== null && _b !== void 0 ? _b : (_e .includeUUIDs = INCLUDE_UUID$1);
11455
+ (_c = (_f = this.parameters).includeState) !== null && _c !== void 0 ? _c : (_f .includeState = INCLUDE_STATE);
11443
11456
if (this.parameters.limit)
11444
11457
this.parameters.limit = Math.min(this.parameters.limit, MAXIMUM_COUNT);
11445
11458
else
11446
11459
this.parameters.limit = MAXIMUM_COUNT;
11447
- (_d = (_h = this.parameters).offset) !== null && _d !== void 0 ? _d : (_h.offset = 0);
11448
11460
}
11449
11461
operation() {
11450
11462
const { channels = [], channelGroups = [] } = this.parameters;
11465
11477
const totalOccupancy = 'occupancy' in serviceResponse ? serviceResponse.occupancy : serviceResponse.payload.total_occupancy;
11466
11478
const channelsPresence = {};
11467
11479
let channels = {};
11480
+ const limit = this.parameters.limit;
11481
+ let occupancyMatchLimit = false;
11468
11482
// Remap single channel presence to multiple channels presence response.
11469
11483
if ('occupancy' in serviceResponse) {
11470
11484
const channel = this.parameters.channels[0];
@@ -11485,11 +11499,12 @@
11485
11499
name: channel,
11486
11500
occupancy: channelEntry.occupancy,
11487
11501
};
11502
+ if (!occupancyMatchLimit && channelEntry.occupancy === limit)
11503
+ occupancyMatchLimit = true;
11488
11504
});
11489
11505
return {
11490
11506
totalChannels,
11491
11507
totalOccupancy,
11492
- next: 0,
11493
11508
channels: channelsPresence,
11494
11509
};
11495
11510
});
11502
11517
return path;
11503
11518
}
11504
11519
get queryParameters() {
11505
- const { channelGroups, includeUUIDs, includeState, limit, offset, queryParameters } = this.parameters;
11506
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign( {}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (this.operation() === RequestOperation$1.PNHereNowOperation && offset > 0 ? { offset } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
11520
+ const { channelGroups, includeUUIDs, includeState, limit, queryParameters } = this.parameters;
11521
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (this.operation() === RequestOperation$1.PNHereNowOperation ? { limit } : {})), (!includeUUIDs ? { disable_uuids: '1' } : {})), ((includeState !== null && includeState !== void 0 ? includeState : false) ? { state: '1' } : {})), (channelGroups && channelGroups.length > 0 ? { 'channel-group': channelGroups.join(',') } : {})), queryParameters);
11507
11522
}
11508
11523
}
11509
11524
@@ -16778,16 +16793,10 @@
16778
16793
};
16779
16794
if (callback)
16780
16795
return this.sendRequest(request, (status, response) => {
16781
- var _a;
16782
- if (response && response.totalOccupancy === parameters.limit)
16783
- response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
16784
16796
logResponse(response);
16785
16797
callback(status, response);
16786
16798
});
16787
16799
return this.sendRequest(request).then((response) => {
16788
- var _a;
16789
- if (response && response.totalOccupancy === parameters.limit)
16790
- response.next = ((_a = parameters.offset) !== null && _a !== void 0 ? _a : 0) + 1;
16791
16800
logResponse(response);
16792
16801
return response;
16793
16802
});
0 commit comments