From d839bc04d31b7dec376d062a5773ae4f30227802 Mon Sep 17 00:00:00 2001 From: shisoAqron Date: Fri, 29 Sep 2023 12:39:27 +0900 Subject: [PATCH] v1.5.4 --- THIRD_PARTY_LICENSE | 74 +++++++++---------- examples/auto-subscribe/src/main.ts | 4 +- examples/core/src/main.ts | 2 +- examples/p2p-room/src/main.ts | 2 +- examples/sfu-bot/src/main.ts | 2 +- examples/sfu-room/src/main.ts | 2 +- examples/tutorial/src/main.ts | 2 +- package-lock.json | 66 ++++++++--------- packages/common/package.json | 2 +- packages/common/src/promise.ts | 4 +- packages/core/package.json | 6 +- packages/core/src/external/signaling.ts | 4 +- packages/core/src/member/localPerson/index.ts | 18 ++++- .../core/src/plugin/interface/connection.ts | 2 +- .../internal/person/connection/index.ts | 23 ++++-- .../internal/person/connection/sender.ts | 45 ++++++----- .../core/src/plugin/internal/person/member.ts | 2 +- packages/core/src/publication/index.ts | 44 ++++++----- packages/core/src/version.ts | 2 +- packages/room/package.json | 8 +- packages/room/src/index.ts | 1 + packages/room/src/member/local/p2p.ts | 8 +- packages/room/src/member/local/sfu.ts | 8 +- packages/room/src/subscription/index.ts | 4 +- packages/room/src/version.ts | 2 +- packages/rtc-api-client/package.json | 6 +- packages/rtc-rpc-api-client/package.json | 6 +- packages/sfu-api-client/package.json | 4 +- packages/sfu-bot/package.json | 6 +- packages/sfu-bot/src/connection/index.ts | 3 +- packages/sfu-bot/src/connection/sender.ts | 3 + .../src/connection/transport/transport.ts | 8 +- packages/sfu-bot/src/member.ts | 24 +++--- packages/sfu-bot/src/plugin.ts | 22 +++--- packages/sfu-bot/src/version.ts | 2 +- packages/signaling-client/package.json | 2 +- packages/token/package.json | 4 +- 37 files changed, 239 insertions(+), 188 deletions(-) diff --git a/THIRD_PARTY_LICENSE b/THIRD_PARTY_LICENSE index 40371b4..6e10459 100644 --- a/THIRD_PARTY_LICENSE +++ b/THIRD_PARTY_LICENSE @@ -1,4 +1,4 @@ -@skyway-sdk/common@1.4.2 +@skyway-sdk/common@1.4.3 MIT @@ -29,7 +29,7 @@ SOFTWARE. --- -@skyway-sdk/core@1.5.2 +@skyway-sdk/core@1.5.3 MIT @@ -68,7 +68,7 @@ MIT --- -@skyway-sdk/room@1.5.3 +@skyway-sdk/room@1.5.4 MIT @@ -99,7 +99,7 @@ SOFTWARE. --- -@skyway-sdk/rtc-api-client@1.4.2 +@skyway-sdk/rtc-api-client@1.4.3 MIT @@ -130,7 +130,7 @@ SOFTWARE. --- -@skyway-sdk/rtc-rpc-api-client@1.4.2 +@skyway-sdk/rtc-rpc-api-client@1.4.3 MIT @@ -161,7 +161,7 @@ SOFTWARE. --- -@skyway-sdk/sfu-api-client@1.4.2 +@skyway-sdk/sfu-api-client@1.4.3 MIT @@ -192,7 +192,7 @@ SOFTWARE. --- -@skyway-sdk/sfu-bot@1.5.2 +@skyway-sdk/sfu-bot@1.5.3 MIT @@ -223,7 +223,7 @@ SOFTWARE. --- -@skyway-sdk/signaling-client@1.0.1 +@skyway-sdk/signaling-client@1.0.2 MIT @@ -254,7 +254,7 @@ SOFTWARE. --- -@skyway-sdk/token@1.4.2 +@skyway-sdk/token@1.4.3 MIT @@ -285,7 +285,7 @@ SOFTWARE. --- -@types/debug@4.1.8 +@types/debug@4.1.9 MIT @@ -316,33 +316,33 @@ https://github.com/DefinitelyTyped/DefinitelyTyped --- -@types/ms@0.7.31 +@types/ms@0.7.32 MIT https://github.com/DefinitelyTyped/DefinitelyTyped - MIT License - - Copyright (c) Microsoft Corporation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE + MIT License + + Copyright (c) Microsoft Corporation. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE --- @@ -560,7 +560,7 @@ https://github.com/ibc/fake-mediastreamtrack --- -follow-redirects@1.15.2 +follow-redirects@1.15.3 MIT @@ -953,7 +953,7 @@ SOFTWARE. --- -ua-parser-js@1.0.35 +ua-parser-js@1.0.36 MIT @@ -961,7 +961,7 @@ https://github.com/faisalman/ua-parser-js MIT License -Copyright (c) 2012-2021 Faisal Salman <> +Copyright (c) 2012-2023 Faisal Salman <> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -1025,7 +1025,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND --- -whatwg-fetch@3.6.18 +whatwg-fetch@3.6.19 MIT @@ -1094,7 +1094,7 @@ SOFTWARE. --- -ws@8.14.0 +ws@8.14.2 MIT diff --git a/examples/auto-subscribe/src/main.ts b/examples/auto-subscribe/src/main.ts index 1c069b3..7ed7f75 100644 --- a/examples/auto-subscribe/src/main.ts +++ b/examples/auto-subscribe/src/main.ts @@ -50,7 +50,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById( 'js-local-stream' ) as HTMLVideoElement; @@ -174,7 +174,7 @@ const token = new SkyWayAuthToken({ disposeVideoElement(element as HTMLVideoElement); }); messages.textContent += '== You left ===\n'; - room.dispose(); + void room.dispose(); room = undefined; }); diff --git a/examples/core/src/main.ts b/examples/core/src/main.ts index 00473dc..2242277 100644 --- a/examples/core/src/main.ts +++ b/examples/core/src/main.ts @@ -52,7 +52,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById('local-video') as HTMLVideoElement; const buttonArea = document.getElementById('button-area'); const remoteMediaArea = document.getElementById('remote-media-area'); diff --git a/examples/p2p-room/src/main.ts b/examples/p2p-room/src/main.ts index b73288f..7e39ae3 100644 --- a/examples/p2p-room/src/main.ts +++ b/examples/p2p-room/src/main.ts @@ -52,7 +52,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById('local-video') as HTMLVideoElement; const buttonArea = document.getElementById('button-area'); const remoteMediaArea = document.getElementById('remote-media-area'); diff --git a/examples/sfu-bot/src/main.ts b/examples/sfu-bot/src/main.ts index 2544d61..366bf2b 100644 --- a/examples/sfu-bot/src/main.ts +++ b/examples/sfu-bot/src/main.ts @@ -54,7 +54,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById('local-video') as HTMLVideoElement; const buttonArea = document.getElementById('button-area'); const remoteMediaArea = document.getElementById('remote-media-area'); diff --git a/examples/sfu-room/src/main.ts b/examples/sfu-room/src/main.ts index fd46bf3..abcd52a 100644 --- a/examples/sfu-room/src/main.ts +++ b/examples/sfu-room/src/main.ts @@ -52,7 +52,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById('local-video') as HTMLVideoElement; const buttonArea = document.getElementById('button-area'); const remoteMediaArea = document.getElementById('remote-media-area'); diff --git a/examples/tutorial/src/main.ts b/examples/tutorial/src/main.ts index e4624a7..3eea8df 100644 --- a/examples/tutorial/src/main.ts +++ b/examples/tutorial/src/main.ts @@ -53,7 +53,7 @@ const token = new SkyWayAuthToken({ }, }).encode(secret); -(async () => { +void (async () => { const localVideo = document.getElementById('local-video') as HTMLVideoElement; const buttonArea = document.getElementById('button-area'); const remoteMediaArea = document.getElementById('remote-media-area'); diff --git a/package-lock.json b/package-lock.json index b0f382d..250060e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22705,7 +22705,7 @@ }, "packages/common": { "name": "@skyway-sdk/common", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { "axios": "^0.23.0" @@ -22722,11 +22722,11 @@ }, "packages/core": { "name": "@skyway-sdk/core", - "version": "1.5.2", + "version": "1.5.3", "license": "MIT", "dependencies": { - "@skyway-sdk/rtc-api-client": "^1.4.2", - "@skyway-sdk/signaling-client": "^1.0.1", + "@skyway-sdk/rtc-api-client": "^1.4.3", + "@skyway-sdk/signaling-client": "^1.0.2", "bowser": "^2.11.0", "deepmerge": "^4.2.2", "sdp-transform": "^2.14.1", @@ -22773,11 +22773,11 @@ }, "packages/room": { "name": "@skyway-sdk/room", - "version": "1.5.3", + "version": "1.5.4", "license": "MIT", "dependencies": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-bot": "^1.5.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-bot": "^1.5.3", "uuid": "^9.0.0" }, "devDependencies": { @@ -22795,11 +22795,11 @@ }, "packages/rtc-api-client": { "name": "@skyway-sdk/rtc-api-client", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { - "@skyway-sdk/rtc-rpc-api-client": "^1.4.2", - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/rtc-rpc-api-client": "^1.4.3", + "@skyway-sdk/token": "^1.4.3", "deepmerge": "^4.2.2", "uuid": "^9.0.0" }, @@ -22818,16 +22818,16 @@ }, "packages/rtc-rpc-api-client": { "name": "@skyway-sdk/rtc-rpc-api-client", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "@skyway-sdk/model": "^1.0.0", "isomorphic-ws": "^4.0.1", "uuid": "^9.0.0" }, "devDependencies": { - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/token": "^1.4.3", "@types/uuid": "^9.0.1" } }, @@ -22842,21 +22842,21 @@ }, "packages/sfu-api-client": { "name": "@skyway-sdk/sfu-api-client", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "mediasoup-client": "^3.6.52" }, "devDependencies": {} }, "packages/sfu-bot": { "name": "@skyway-sdk/sfu-bot", - "version": "1.5.2", + "version": "1.5.3", "license": "MIT", "dependencies": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-api-client": "^1.4.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-api-client": "^1.4.3", "lodash": "4.17.21", "mediasoup-client": "3.6.82" }, @@ -22864,7 +22864,7 @@ }, "packages/signaling-client": { "name": "@skyway-sdk/signaling-client", - "version": "1.0.1", + "version": "1.0.2", "license": "MIT", "dependencies": { "isomorphic-fetch": "^3.0.0", @@ -24266,10 +24266,10 @@ }, "packages/token": { "name": "@skyway-sdk/token", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "jsrsasign": "^10.6.0", "jwt-decode": "3.1.2", "uuid": "^9.0.0" @@ -29483,8 +29483,8 @@ "@skyway-sdk/core": { "version": "file:packages/core", "requires": { - "@skyway-sdk/rtc-api-client": "^1.4.2", - "@skyway-sdk/signaling-client": "^1.0.1", + "@skyway-sdk/rtc-api-client": "^1.4.3", + "@skyway-sdk/signaling-client": "^1.0.2", "@types/sdp-transform": "^2.4.5", "@types/ua-parser-js": "^0.7.36", "@types/uuid": "^9.0.1", @@ -29513,8 +29513,8 @@ "@skyway-sdk/room": { "version": "file:packages/room", "requires": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-bot": "^1.5.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-bot": "^1.5.3", "@types/uuid": "^9.0.1", "uuid": "^9.0.0" }, @@ -29529,8 +29529,8 @@ "@skyway-sdk/rtc-api-client": { "version": "file:packages/rtc-api-client", "requires": { - "@skyway-sdk/rtc-rpc-api-client": "^1.4.2", - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/rtc-rpc-api-client": "^1.4.3", + "@skyway-sdk/token": "^1.4.3", "@types/uuid": "^9.0.1", "deepmerge": "^4.2.2", "uuid": "^9.0.0" @@ -29546,9 +29546,9 @@ "@skyway-sdk/rtc-rpc-api-client": { "version": "file:packages/rtc-rpc-api-client", "requires": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "@skyway-sdk/model": "^1.0.0", - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/token": "^1.4.3", "@types/uuid": "^9.0.1", "isomorphic-ws": "^4.0.1", "uuid": "^9.0.0" @@ -29564,15 +29564,15 @@ "@skyway-sdk/sfu-api-client": { "version": "file:packages/sfu-api-client", "requires": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "mediasoup-client": "^3.6.52" } }, "@skyway-sdk/sfu-bot": { "version": "file:packages/sfu-bot", "requires": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-api-client": "^1.4.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-api-client": "^1.4.3", "lodash": "4.17.21", "mediasoup-client": "3.6.82" } @@ -30657,7 +30657,7 @@ "@skyway-sdk/token": { "version": "file:packages/token", "requires": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "@types/jsrsasign": "^10.5.4", "@types/uuid": "^9.0.1", "jsrsasign": "^10.6.0", diff --git a/packages/common/package.json b/packages/common/package.json index d5aaeaa..b36e180 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/common", - "version": "1.4.2", + "version": "1.4.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { diff --git a/packages/common/src/promise.ts b/packages/common/src/promise.ts index 5f47948..acde962 100644 --- a/packages/common/src/promise.ts +++ b/packages/common/src/promise.ts @@ -16,7 +16,9 @@ export class PromiseQueue { new Promise((r, f) => { this.queue.push({ promise, done: r, failed: f }); if (!this.running) { - this.run(); + this.run().catch((e) => { + log.error('push', e); + }); } }); diff --git a/packages/core/package.json b/packages/core/package.json index 759061e..235bfd8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/core", - "version": "1.5.2", + "version": "1.5.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -47,8 +47,8 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/rtc-api-client": "^1.4.2", - "@skyway-sdk/signaling-client": "^1.0.1", + "@skyway-sdk/rtc-api-client": "^1.4.3", + "@skyway-sdk/signaling-client": "^1.0.2", "bowser": "^2.11.0", "deepmerge": "^4.2.2", "sdp-transform": "^2.14.1", diff --git a/packages/core/src/external/signaling.ts b/packages/core/src/external/signaling.ts index fb84f4d..f8492b8 100644 --- a/packages/core/src/external/signaling.ts +++ b/packages/core/src/external/signaling.ts @@ -1,4 +1,4 @@ -import { BackOff, Event, Logger, SkyWayError } from '@skyway-sdk/common'; +import { BackOff, Event, Logger } from '@skyway-sdk/common'; import { Member } from '@skyway-sdk/model'; import { ConnectionState, SignalingClient } from '@skyway-sdk/signaling-client'; import { uuidV4 } from '@skyway-sdk/token'; @@ -152,7 +152,7 @@ export class SignalingSession { }), e ); - this._updateSkyWayAuthToken(token); + await this._updateSkyWayAuthToken(token); return; } diff --git a/packages/core/src/member/localPerson/index.ts b/packages/core/src/member/localPerson/index.ts index 755a0b2..22a0ed6 100644 --- a/packages/core/src/member/localPerson/index.ts +++ b/packages/core/src/member/localPerson/index.ts @@ -460,6 +460,12 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson { } stream.published = true; + if (options.codecCapabilities) { + options.codecCapabilities = options.codecCapabilities.filter( + (c) => c != undefined + ); + } + const init: PublicationInit = { metadata: options.metadata, publisher: this.id, @@ -571,7 +577,9 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson { .map((s) => s.subscriber) .forEach((s) => { if (isRemoteMember(s)) { - this._publishingAgent.stopPublishing(publication, s); + this._publishingAgent.stopPublishing(publication, s).catch((e) => { + log.error('[failed] stopPublishing', e, { publication }); + }); } }); @@ -668,6 +676,7 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson { subscription.publication.id === publicationId, this.context.config.rtcApi.timeout ) + .then(r) .catch(async (e) => { if (subscribing.processing) { f( @@ -686,8 +695,7 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson { }) ); } - }) - .then(r); + }); }), new Promise((r, f) => { this.channel.onMemberLeft @@ -888,7 +896,9 @@ export class LocalPersonImpl extends MemberImpl implements LocalPerson { if (this._signaling) { this._signaling.close(); } - this._getConnections().forEach((c) => c.close()); + this._getConnections().forEach((c) => + c.close({ reason: 'localPerson disposed' }) + ); this._onDisposed.emit(); this._events.dispose(); diff --git a/packages/core/src/plugin/interface/connection.ts b/packages/core/src/plugin/interface/connection.ts index 9f2b424..aaa241b 100644 --- a/packages/core/src/plugin/interface/connection.ts +++ b/packages/core/src/plugin/interface/connection.ts @@ -13,7 +13,7 @@ export interface SkyWayConnection { readonly onDisconnect: Event; readonly onClose: Event; closed: boolean; - close(): void; + close(props?: { reason?: string }): void; /**@throws {SkyWayError} */ startPublishing?(publication: PublicationImpl): Promise; stopPublishing?(publication: PublicationImpl): Promise; diff --git a/packages/core/src/plugin/internal/person/connection/index.ts b/packages/core/src/plugin/internal/person/connection/index.ts index 7aeab67..ad734a6 100644 --- a/packages/core/src/plugin/internal/person/connection/index.ts +++ b/packages/core/src/plugin/internal/person/connection/index.ts @@ -81,9 +81,14 @@ export class P2PConnection implements SkyWayConnection { async stopPublishing(publication: Publication) { await this._pubsubQueue.push(async () => { this._log.debug(' start', { publication }); - this.sender.remove(publication.id).then(() => { - this._log.debug(' removed', { publication }); - }); + this.sender + .remove(publication.id) + .then(() => { + this._log.debug(' removed', { publication }); + }) + .catch((e) => { + this._log.error(' remove failed', e, { publication }); + }); this._closeIfNeeded(); this._log.debug(' end', { publication }); }); @@ -132,7 +137,7 @@ export class P2PConnection implements SkyWayConnection { private _closeIfNeeded(): void { if (this.sender.hasMedia || this.receiver.hasMedia) return; - this.close(); + this.close({ reason: 'no media' }); } async getStats(content: Subscription | Publication) { @@ -163,13 +168,19 @@ export class P2PConnection implements SkyWayConnection { } /**@internal */ - close() { + close({ reason }: { reason?: string } = {}) { if (this.closed) { return; } this.closed = true; - this._log.debug('closed', { endpointId: this.remoteMember.id }); + this._log.debug('closed', { + endpointId: this.remoteMember.id, + reason, + sender: this.sender.id, + receiver: this.receiver.id, + id: this.id, + }); this.sender.close(); this.receiver.close(); diff --git a/packages/core/src/plugin/internal/person/connection/sender.ts b/packages/core/src/plugin/internal/person/connection/sender.ts index cedb568..56002b7 100644 --- a/packages/core/src/plugin/internal/person/connection/sender.ts +++ b/packages/core/src/plugin/internal/person/connection/sender.ts @@ -111,27 +111,31 @@ export class Sender extends Peer { this.onPeerConnectionStateChanged .add(async (state) => { - log.debug('onPeerConnectionStateChanged', { state }); - switch (state) { - case 'disconnected': - case 'failed': - { - const e = await this.waitForConnectionState( - 'connected', - context.config.rtcConfig.iceDisconnectBufferTimeout - ).catch((e) => e as SkyWayError); - if (e && this._connectionState !== 'reconnecting') { - await this.restartIce(); + try { + log.debug('onPeerConnectionStateChanged', { state }); + switch (state) { + case 'disconnected': + case 'failed': + { + const e = await this.waitForConnectionState( + 'connected', + context.config.rtcConfig.iceDisconnectBufferTimeout + ).catch((e) => e as SkyWayError); + if (e && this._connectionState !== 'reconnecting') { + await this.restartIce(); + } } - } - break; - case 'connecting': - case 'connected': - this._setConnectionState(state); - break; - case 'closed': - this._setConnectionState('disconnected'); - break; + break; + case 'connecting': + case 'connected': + this._setConnectionState(state); + break; + case 'closed': + this._setConnectionState('disconnected'); + break; + } + } catch (error) { + log.error('onPeerConnectionStateChanged', error, this.id); } }) .disposer(this._disposer); @@ -151,6 +155,7 @@ export class Sender extends Peer { this.onConnectionStateChanged.emit(state); } + /**@throws */ readonly restartIce = async () => { if (this._backoffIceRestarted.exceeded) { this._log.error( diff --git a/packages/core/src/plugin/internal/person/member.ts b/packages/core/src/plugin/internal/person/member.ts index 86bc618..f389c19 100644 --- a/packages/core/src/plugin/internal/person/member.ts +++ b/packages/core/src/plugin/internal/person/member.ts @@ -105,7 +105,7 @@ export class RemotePersonImpl extends MemberImpl implements RemotePerson { this.onLeft.once(() => { log.debug('RemotePerson left: ', this.toJSON()); Object.values(this._connections).forEach((connection) => { - connection.close(); + connection.close({ reason: 'remote person left' }); }); this._connections = {}; }); diff --git a/packages/core/src/publication/index.ts b/packages/core/src/publication/index.ts index bbb06aa..1cbd6c4 100644 --- a/packages/core/src/publication/index.ts +++ b/packages/core/src/publication/index.ts @@ -317,6 +317,18 @@ export class PublicationImpl (e) => e.metadata === metadata, this._context.config.rtcApi.timeout ) + .then(async () => { + r(); + log.elapsed( + timestamp, + '[end] updateMetadata', + await createLogPayload({ + operationName: 'Publication.updateMetadata', + channel: this._channel, + }), + this + ); + }) .catch((error) => { if (!failed) { throw createError({ @@ -331,18 +343,6 @@ export class PublicationImpl error, }); } - }) - .then(async () => { - r(); - log.elapsed( - timestamp, - '[end] updateMetadata', - await createLogPayload({ - operationName: 'Publication.updateMetadata', - channel: this._channel, - }), - this - ); }); }); @@ -418,9 +418,11 @@ export class PublicationImpl createLogPayload({ operationName: 'Publication._disableStream', channel: this._channel, - }).then((p) => - log.info('publication _disableStream', p, { publication: this }) - ); + }) + .then((p) => + log.info('publication _disableStream', p, { publication: this }) + ) + .catch(() => {}); } enable = () => @@ -490,9 +492,11 @@ export class PublicationImpl createLogPayload({ operationName: 'Publication._enableStream', channel: this._channel, - }).then((p) => - log.info('publication _enableStream', p, { publication: this }) - ); + }) + .then((p) => + log.info('publication _enableStream', p, { publication: this }) + ) + .catch(() => {}); if (this.stream.contentType === 'data') { this.stream.setIsEnabled(true); @@ -545,7 +549,9 @@ export class PublicationImpl .then((res) => log.debug(res, { old: this.stream, new: stream })) .catch((e) => e); - stream.setEnabled(this.stream.isEnabled); + stream.setEnabled(this.stream.isEnabled).catch((e) => { + log.error('replaceStream stream.setEnabled', e, this.toJSON()); + }); this._setStream(stream as T); this._onReplaceStream.emit(stream); diff --git a/packages/core/src/version.ts b/packages/core/src/version.ts index b98db40..9fd53b9 100644 --- a/packages/core/src/version.ts +++ b/packages/core/src/version.ts @@ -1 +1 @@ -export const PACKAGE_VERSION = '1.5.2'; +export const PACKAGE_VERSION = '1.5.3'; diff --git a/packages/room/package.json b/packages/room/package.json index 0ffd5fa..4b1ad14 100644 --- a/packages/room/package.json +++ b/packages/room/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/room", - "version": "1.5.3", + "version": "1.5.4", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -32,7 +32,7 @@ "format": "eslint ./src --fix && eslint ./tests --fix", "graph": "dependency-cruiser --include-only '^src' --output-type dot src | dot -T svg > docs/dependencygraph.svg", "jest": "jest", - "lint": "eslint ./src --fix && eslint ./e2e --fix", + "lint": "eslint ./src --fix && eslint ./tests --fix", "publish:npm": "npx can-npm-publish --verbose && npm run build && npm publish --access public", "test-extra": "karma start ./karma.extra.js --single-run --browsers chrome_headless_with_fake_device", "test-extra:dev": "karma start ./karma.extra.js --browsers chrome_with_fake_device", @@ -46,8 +46,8 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-bot": "^1.5.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-bot": "^1.5.3", "uuid": "^9.0.0" }, "devDependencies": { diff --git a/packages/room/src/index.ts b/packages/room/src/index.ts index ac23684..9f4a56e 100644 --- a/packages/room/src/index.ts +++ b/packages/room/src/index.ts @@ -28,6 +28,7 @@ export { Event, Events, getBitrateFromPeerConnection, + getRtcRtpCapabilities, LocalAudioStream, LocalDataStream, LocalMediaStreamBase, diff --git a/packages/room/src/member/local/p2p.ts b/packages/room/src/member/local/p2p.ts index f56bbe5..dbb1efb 100644 --- a/packages/room/src/member/local/p2p.ts +++ b/packages/room/src/member/local/p2p.ts @@ -55,7 +55,9 @@ export class LocalP2PRoomMemberImpl async unpublish(target: string | RoomPublication) { const publicationId = typeof target === 'string' ? target : target.id; - this._local.unpublish(publicationId); + this._local.unpublish(publicationId).catch((error) => { + log.error('unpublish', error, { target }, this.toJSON()); + }); const { publication } = await this.room.onStreamUnpublished .watch( (e) => e.publication.id === publicationId, @@ -95,7 +97,9 @@ export class LocalP2PRoomMemberImpl async unsubscribe(target: string | RoomSubscription) { const subscriptionId = typeof target === 'string' ? target : target.id; - this._local.unsubscribe(subscriptionId); + this._local.unsubscribe(subscriptionId).catch((error) => { + log.error('unsubscribe', error, { target }, this.toJSON()); + }); await this.room.onPublicationUnsubscribed .watch( (e) => e.subscription.id === subscriptionId, diff --git a/packages/room/src/member/local/sfu.ts b/packages/room/src/member/local/sfu.ts index 4f17256..686f104 100644 --- a/packages/room/src/member/local/sfu.ts +++ b/packages/room/src/member/local/sfu.ts @@ -103,7 +103,9 @@ export class LocalSFURoomMemberImpl }); } - this._local.unpublish(origin.id); + this._local.unpublish(origin.id).catch((error) => { + log.error('unpublish error', error, { target }, this.toJSON()); + }); await this.room.onStreamUnpublished .watch( (e) => e.publication.id === publicationId, @@ -153,7 +155,9 @@ export class LocalSFURoomMemberImpl */ async unsubscribe(target: string | RoomSubscription) { const subscriptionId = typeof target === 'string' ? target : target.id; - this._local.unsubscribe(subscriptionId); + this._local.unsubscribe(subscriptionId).catch((error) => { + log.error('unsubscribe error', error, { target }, this.toJSON()); + }); await this.room.onPublicationUnsubscribed .watch( (e) => e.subscription.id === subscriptionId, diff --git a/packages/room/src/subscription/index.ts b/packages/room/src/subscription/index.ts index b77ec62..000bb65 100644 --- a/packages/room/src/subscription/index.ts +++ b/packages/room/src/subscription/index.ts @@ -130,7 +130,9 @@ export class RoomSubscriptionImpl< } async cancel() { - this._subscription.cancel(); + this._subscription.cancel().catch((error) => { + log.error('subscription.cancel', error, this.toJSON()); + }); await this._room.onPublicationUnsubscribed .watch( (e) => e.subscription.id === this.id, diff --git a/packages/room/src/version.ts b/packages/room/src/version.ts index 9fd53b9..cbf1464 100644 --- a/packages/room/src/version.ts +++ b/packages/room/src/version.ts @@ -1 +1 @@ -export const PACKAGE_VERSION = '1.5.3'; +export const PACKAGE_VERSION = '1.5.4'; diff --git a/packages/rtc-api-client/package.json b/packages/rtc-api-client/package.json index 61e0b73..73e8ac6 100644 --- a/packages/rtc-api-client/package.json +++ b/packages/rtc-api-client/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/rtc-api-client", - "version": "1.4.2", + "version": "1.4.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -35,8 +35,8 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/rtc-rpc-api-client": "^1.4.2", - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/rtc-rpc-api-client": "^1.4.3", + "@skyway-sdk/token": "^1.4.3", "deepmerge": "^4.2.2", "uuid": "^9.0.0" }, diff --git a/packages/rtc-rpc-api-client/package.json b/packages/rtc-rpc-api-client/package.json index ca069f8..c077c79 100644 --- a/packages/rtc-rpc-api-client/package.json +++ b/packages/rtc-rpc-api-client/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/rtc-rpc-api-client", - "version": "1.4.2", + "version": "1.4.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -34,13 +34,13 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "@skyway-sdk/model": "^1.0.0", "isomorphic-ws": "^4.0.1", "uuid": "^9.0.0" }, "devDependencies": { - "@skyway-sdk/token": "^1.4.2", + "@skyway-sdk/token": "^1.4.3", "@types/uuid": "^9.0.1" } } diff --git a/packages/sfu-api-client/package.json b/packages/sfu-api-client/package.json index 74900a6..87d7260 100644 --- a/packages/sfu-api-client/package.json +++ b/packages/sfu-api-client/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/sfu-api-client", - "version": "1.4.2", + "version": "1.4.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -35,7 +35,7 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "mediasoup-client": "^3.6.52" }, "devDependencies": {} diff --git a/packages/sfu-bot/package.json b/packages/sfu-bot/package.json index 55f5293..65238b2 100644 --- a/packages/sfu-bot/package.json +++ b/packages/sfu-bot/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/sfu-bot", - "version": "1.5.2", + "version": "1.5.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -41,8 +41,8 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/core": "^1.5.2", - "@skyway-sdk/sfu-api-client": "^1.4.2", + "@skyway-sdk/core": "^1.5.3", + "@skyway-sdk/sfu-api-client": "^1.4.3", "lodash": "4.17.21", "mediasoup-client": "3.6.82" }, diff --git a/packages/sfu-bot/src/connection/index.ts b/packages/sfu-bot/src/connection/index.ts index ea25847..6c49591 100644 --- a/packages/sfu-bot/src/connection/index.ts +++ b/packages/sfu-bot/src/connection/index.ts @@ -125,13 +125,14 @@ export class SFUConnection implements SkyWayConnection { } /**@internal */ - close() { + close({ reason }: { reason?: string } = {}) { if (this.closed) { return; } log.debug('close sfu connection', { remote: this.remoteMember, local: this.localPerson, + reason, }); this.closed = true; diff --git a/packages/sfu-bot/src/connection/sender.ts b/packages/sfu-bot/src/connection/sender.ts index ea53047..e11d3cd 100644 --- a/packages/sfu-bot/src/connection/sender.ts +++ b/packages/sfu-bot/src/connection/sender.ts @@ -435,6 +435,9 @@ export class Sender { } catch (error) { producer.errback(error); } + }) + .catch((e) => { + log.error('onProduce failed', e, this); }); log.debug('[start] msTransport.produce', this); const producer = await transport.msTransport diff --git a/packages/sfu-bot/src/connection/transport/transport.ts b/packages/sfu-bot/src/connection/transport/transport.ts index eddbe54..d314c3b 100644 --- a/packages/sfu-bot/src/connection/transport/transport.ts +++ b/packages/sfu-bot/src/connection/transport/transport.ts @@ -110,9 +110,11 @@ export class SfuTransport { createLogPayload({ operationName: 'onMediasoupConnectionStateChanged', channel: this._bot.channel, - }).then((debug) => { - log.debug(debug, { state, transportId: this.id, bot: _bot }); - }); + }) + .then((debug) => { + log.debug(debug, { state, transportId: this.id, bot: _bot }); + }) + .catch(() => {}); switch (state) { case 'disconnected': diff --git a/packages/sfu-bot/src/member.ts b/packages/sfu-bot/src/member.ts index 28f5dd7..edf0ce3 100644 --- a/packages/sfu-bot/src/member.ts +++ b/packages/sfu-bot/src/member.ts @@ -75,7 +75,7 @@ export class SfuBotMember this.onLeft.once(() => { log.debug('SfuBotMember left: ', { id: this.id }); Object.values(this._connections).forEach((c) => { - c.close(); + c.close({ reason: 'sfu bot left' }); }); this._connections = {}; }); @@ -329,6 +329,17 @@ export class SfuBotMember (e) => e.forwarding.id === forwardingId, this._context.config.rtcApi.timeout ) + .then(async () => { + log.elapsed( + timestamp, + '[end] stopForwarding', + await createLogPayload({ + operationName: 'SfuBotMember.stopForwarding', + channel: this.channel, + }) + ); + r(); + }) .catch((error) => { if (!failed) f( @@ -342,17 +353,6 @@ export class SfuBotMember error, }) ); - }) - .then(async () => { - log.elapsed( - timestamp, - '[end] stopForwarding', - await createLogPayload({ - operationName: 'SfuBotMember.stopForwarding', - channel: this.channel, - }) - ); - r(); }); }); diff --git a/packages/sfu-bot/src/plugin.ts b/packages/sfu-bot/src/plugin.ts index 2f44831..39ba5c5 100644 --- a/packages/sfu-bot/src/plugin.ts +++ b/packages/sfu-bot/src/plugin.ts @@ -152,6 +152,17 @@ export class SfuBotPlugin extends SkyWayPlugin { (e) => e.member.id === botId, this._context!.config.rtcApi.timeout ) + .then(async () => { + log.elapsed( + timestamp, + '[end] deleteBot', + await createLogPayload({ + operationName: 'SfuBotPlugin.deleteBot', + channel, + }) + ); + r(); + }) .catch((error) => { if (!failed) f( @@ -164,17 +175,6 @@ export class SfuBotPlugin extends SkyWayPlugin { context: this._context, }) ); - }) - .then(async () => { - log.elapsed( - timestamp, - '[end] deleteBot', - await createLogPayload({ - operationName: 'SfuBotPlugin.deleteBot', - channel, - }) - ); - r(); }); }); } diff --git a/packages/sfu-bot/src/version.ts b/packages/sfu-bot/src/version.ts index b98db40..9fd53b9 100644 --- a/packages/sfu-bot/src/version.ts +++ b/packages/sfu-bot/src/version.ts @@ -1 +1 @@ -export const PACKAGE_VERSION = '1.5.2'; +export const PACKAGE_VERSION = '1.5.3'; diff --git a/packages/signaling-client/package.json b/packages/signaling-client/package.json index f938d45..f0e3106 100644 --- a/packages/signaling-client/package.json +++ b/packages/signaling-client/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/signaling-client", - "version": "1.0.1", + "version": "1.0.2", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { diff --git a/packages/token/package.json b/packages/token/package.json index 6e9d6a2..37a7355 100644 --- a/packages/token/package.json +++ b/packages/token/package.json @@ -1,6 +1,6 @@ { "name": "@skyway-sdk/token", - "version": "1.4.2", + "version": "1.4.3", "description": "The official Next Generation JavaScript SDK for SkyWay", "homepage": "https://skyway.ntt.com/", "repository": { @@ -34,7 +34,7 @@ "watch:tsc": "tsc -p tsconfig.build.json -w" }, "dependencies": { - "@skyway-sdk/common": "^1.4.2", + "@skyway-sdk/common": "^1.4.3", "jsrsasign": "^10.6.0", "jwt-decode": "3.1.2", "uuid": "^9.0.0"