|
3261 | 3261 | userId: this.configuration.userId,
|
3262 | 3262 | heartbeatInterval: this.configuration.heartbeatInterval,
|
3263 | 3263 | logVerbosity: this.configuration.logVerbosity,
|
| 3264 | + workerOfflineClientsCheckInterval: this.configuration.workerOfflineClientsCheckInterval, |
| 3265 | + workerUnsubscribeOfflineClients: this.configuration.workerUnsubscribeOfflineClients, |
3264 | 3266 | workerLogVerbosity: this.configuration.workerLogVerbosity,
|
3265 | 3267 | }, true);
|
3266 | 3268 | this.subscriptionWorker.port.onmessage = (event) => this.handleWorkerEvent(event);
|
|
3433 | 3435 | * Whether configured user presence state should be maintained by the PubNub client or not.
|
3434 | 3436 | */
|
3435 | 3437 | const MAINTAIN_PRESENCE_STATE = true;
|
| 3438 | + /** |
| 3439 | + * Whether heartbeat should be postponed on successful subscribe response or not. |
| 3440 | + */ |
| 3441 | + const USE_SMART_HEARTBEAT = true; |
3436 | 3442 | /**
|
3437 | 3443 | * Whether PubNub client should try to utilize existing TCP connection for new requests or not.
|
3438 | 3444 | */
|
|
3489 | 3495 | * @internal
|
3490 | 3496 | */
|
3491 | 3497 | const setDefaults$1 = (configuration) => {
|
3492 |
| - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; |
| 3498 | + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; |
3493 | 3499 | // Copy configuration.
|
3494 | 3500 | const configurationCopy = Object.assign({}, configuration);
|
3495 | 3501 | (_a = configurationCopy.logVerbosity) !== null && _a !== void 0 ? _a : (configurationCopy.logVerbosity = USE_VERBOSE_LOGGING);
|
|
3504 | 3510 | (_k = configurationCopy.autoNetworkDetection) !== null && _k !== void 0 ? _k : (configurationCopy.autoNetworkDetection = AUTO_NETWORK_DETECTION);
|
3505 | 3511 | (_l = configurationCopy.enableEventEngine) !== null && _l !== void 0 ? _l : (configurationCopy.enableEventEngine = ENABLE_EVENT_ENGINE);
|
3506 | 3512 | (_m = configurationCopy.maintainPresenceState) !== null && _m !== void 0 ? _m : (configurationCopy.maintainPresenceState = MAINTAIN_PRESENCE_STATE);
|
3507 |
| - (_o = configurationCopy.keepAlive) !== null && _o !== void 0 ? _o : (configurationCopy.keepAlive = KEEP_ALIVE$1); |
| 3513 | + (_o = configurationCopy.useSmartHeartbeat) !== null && _o !== void 0 ? _o : (configurationCopy.useSmartHeartbeat = USE_SMART_HEARTBEAT); |
| 3514 | + (_p = configurationCopy.keepAlive) !== null && _p !== void 0 ? _p : (configurationCopy.keepAlive = KEEP_ALIVE$1); |
3508 | 3515 | if (configurationCopy.userId && configurationCopy.uuid)
|
3509 | 3516 | throw new PubNubError("PubNub client configuration error: use only 'userId'");
|
3510 |
| - (_p = configurationCopy.userId) !== null && _p !== void 0 ? _p : (configurationCopy.userId = configurationCopy.uuid); |
| 3517 | + (_q = configurationCopy.userId) !== null && _q !== void 0 ? _q : (configurationCopy.userId = configurationCopy.uuid); |
3511 | 3518 | if (!configurationCopy.userId)
|
3512 | 3519 | throw new PubNubError("PubNub client configuration error: 'userId' not set");
|
3513 |
| - else if (((_q = configurationCopy.userId) === null || _q === void 0 ? void 0 : _q.trim().length) === 0) |
| 3520 | + else if (((_r = configurationCopy.userId) === null || _r === void 0 ? void 0 : _r.trim().length) === 0) |
3514 | 3521 | throw new PubNubError("PubNub client configuration error: 'userId' is empty");
|
3515 | 3522 | // Generate default origin subdomains.
|
3516 | 3523 | if (!configurationCopy.origin)
|
|
3599 | 3606 | * Whether verbose logging should be enabled for `Subscription` worker to print debug messages or not.
|
3600 | 3607 | */
|
3601 | 3608 | const SUBSCRIPTION_WORKER_LOG_VERBOSITY = false;
|
| 3609 | + /** |
| 3610 | + * Interval at which Shared Worker should check whether PubNub instances which used it still active or not. |
| 3611 | + */ |
| 3612 | + const SUBSCRIPTION_WORKER_OFFLINE_CLIENTS_CHECK_INTERVAL = 10; |
| 3613 | + /** |
| 3614 | + * Whether `leave` request should be sent for _offline_ PubNub client or not. |
| 3615 | + */ |
| 3616 | + const SUBSCRIPTION_WORKER_UNSUBSCRIBE_OFFLINE_CLIENTS = false; |
3602 | 3617 | /**
|
3603 | 3618 | * Use modern Web Fetch API for network requests by default.
|
3604 | 3619 | */
|
|
3615 | 3630 | * @internal
|
3616 | 3631 | */
|
3617 | 3632 | const setDefaults = (configuration) => {
|
3618 |
| - var _a, _b, _c, _d; |
| 3633 | + var _a, _b, _c, _d, _e, _f; |
3619 | 3634 | // Force disable service workers if environment doesn't support them.
|
3620 | 3635 | if (configuration.subscriptionWorkerUrl && typeof SharedWorker === 'undefined')
|
3621 | 3636 | configuration.subscriptionWorkerUrl = null;
|
3622 | 3637 | return Object.assign(Object.assign({}, setDefaults$1(configuration)), {
|
3623 | 3638 | // Set platform-specific options.
|
3624 |
| - listenToBrowserNetworkEvents: (_a = configuration.listenToBrowserNetworkEvents) !== null && _a !== void 0 ? _a : LISTEN_TO_BROWSER_NETWORK_EVENTS, subscriptionWorkerUrl: configuration.subscriptionWorkerUrl, subscriptionWorkerLogVerbosity: (_b = configuration.subscriptionWorkerLogVerbosity) !== null && _b !== void 0 ? _b : SUBSCRIPTION_WORKER_LOG_VERBOSITY, transport: (_c = configuration.transport) !== null && _c !== void 0 ? _c : TRANSPORT, keepAlive: (_d = configuration.keepAlive) !== null && _d !== void 0 ? _d : KEEP_ALIVE }); |
| 3639 | + listenToBrowserNetworkEvents: (_a = configuration.listenToBrowserNetworkEvents) !== null && _a !== void 0 ? _a : LISTEN_TO_BROWSER_NETWORK_EVENTS, subscriptionWorkerUrl: configuration.subscriptionWorkerUrl, subscriptionWorkerOfflineClientsCheckInterval: (_b = configuration.subscriptionWorkerOfflineClientsCheckInterval) !== null && _b !== void 0 ? _b : SUBSCRIPTION_WORKER_OFFLINE_CLIENTS_CHECK_INTERVAL, subscriptionWorkerUnsubscribeOfflineClients: (_c = configuration.subscriptionWorkerUnsubscribeOfflineClients) !== null && _c !== void 0 ? _c : SUBSCRIPTION_WORKER_UNSUBSCRIBE_OFFLINE_CLIENTS, subscriptionWorkerLogVerbosity: (_d = configuration.subscriptionWorkerLogVerbosity) !== null && _d !== void 0 ? _d : SUBSCRIPTION_WORKER_LOG_VERBOSITY, transport: (_e = configuration.transport) !== null && _e !== void 0 ? _e : TRANSPORT, keepAlive: (_f = configuration.keepAlive) !== null && _f !== void 0 ? _f : KEEP_ALIVE }); |
3625 | 3640 | };
|
3626 | 3641 |
|
3627 | 3642 | var uuid = {exports: {}};
|
|
3803 | 3818 | return base.PubNubFile;
|
3804 | 3819 | },
|
3805 | 3820 | get version() {
|
3806 |
| - return '8.9.1'; |
| 3821 | + return '8.10.0'; |
3807 | 3822 | },
|
3808 | 3823 | getVersion() {
|
3809 | 3824 | return this.version;
|
|
4930 | 4945 | */
|
4931 | 4946 | reconnect(forUnsubscribe = false) {
|
4932 | 4947 | this.startSubscribeLoop();
|
4933 |
| - if (!forUnsubscribe) |
| 4948 | + if (!forUnsubscribe && this.configuration.useSmartHeartbeat) |
4934 | 4949 | this.startHeartbeatTimer();
|
4935 | 4950 | }
|
4936 | 4951 | /**
|
|
14565 | 14580 | workerUrl: configurationCopy.subscriptionWorkerUrl,
|
14566 | 14581 | sdkVersion: clientConfiguration.getVersion(),
|
14567 | 14582 | heartbeatInterval: clientConfiguration.getHeartbeatInterval(),
|
| 14583 | + workerOfflineClientsCheckInterval: platformConfiguration.subscriptionWorkerOfflineClientsCheckInterval, |
| 14584 | + workerUnsubscribeOfflineClients: platformConfiguration.subscriptionWorkerUnsubscribeOfflineClients, |
14568 | 14585 | logVerbosity: clientConfiguration.logVerbosity,
|
14569 | 14586 | workerLogVerbosity: platformConfiguration.subscriptionWorkerLogVerbosity,
|
14570 | 14587 | transport,
|
|
0 commit comments