livekit-client 1.8.0 → 1.9.0
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.
- package/README.md +3 -2
- package/dist/livekit-client.esm.mjs +13470 -13341
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +11 -10
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/connectionHelper/ConnectionCheck.d.ts +1 -1
- package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -1
- package/dist/src/connectionHelper/checks/Checker.d.ts +1 -1
- package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -1
- package/dist/src/index.d.ts +5 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/proto/livekit_models.d.ts +5 -0
- package/dist/src/proto/livekit_models.d.ts.map +1 -1
- package/dist/src/proto/livekit_rtc.d.ts +32 -0
- package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +5 -3
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +19 -15
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +15 -0
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts +14 -2
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +4 -2
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts +2 -2
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts +1 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteAudioTrack.d.ts +1 -1
- package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/types.d.ts +1 -0
- package/dist/src/room/types.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +14 -10
- package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +1 -1
- package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +1 -1
- package/dist/ts4.2/src/index.d.ts +6 -7
- package/dist/ts4.2/src/proto/livekit_models.d.ts +5 -0
- package/dist/ts4.2/src/proto/livekit_rtc.d.ts +32 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +5 -3
- package/dist/ts4.2/src/room/Room.d.ts +19 -15
- package/dist/ts4.2/src/room/events.d.ts +15 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +14 -2
- package/dist/ts4.2/src/room/participant/Participant.d.ts +4 -2
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +2 -2
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
- package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/types.d.ts +1 -0
- package/package.json +4 -3
- package/src/api/SignalClient.ts +38 -26
- package/src/connectionHelper/ConnectionCheck.ts +1 -2
- package/src/connectionHelper/checks/Checker.ts +1 -1
- package/src/connectionHelper/checks/reconnect.ts +1 -1
- package/src/index.ts +8 -10
- package/src/proto/livekit_models.ts +15 -0
- package/src/room/RTCEngine.ts +32 -11
- package/src/room/RegionUrlProvider.ts +1 -1
- package/src/room/Room.ts +102 -70
- package/src/room/events.ts +17 -0
- package/src/room/participant/LocalParticipant.ts +30 -7
- package/src/room/participant/Participant.ts +27 -3
- package/src/room/participant/RemoteParticipant.ts +6 -3
- package/src/room/participant/publishUtils.test.ts +1 -1
- package/src/room/participant/publishUtils.ts +1 -1
- package/src/room/track/LocalAudioTrack.ts +1 -1
- package/src/room/track/LocalTrack.ts +2 -2
- package/src/room/track/LocalTrackPublication.ts +1 -1
- package/src/room/track/LocalVideoTrack.ts +3 -3
- package/src/room/track/RemoteAudioTrack.ts +1 -1
- package/src/room/track/RemoteVideoTrack.test.ts +1 -1
- package/src/room/track/RemoteVideoTrack.ts +3 -3
- package/src/room/track/create.ts +2 -2
- package/src/room/types.ts +11 -0
@@ -2,9 +2,9 @@ import type { TrackInfo } from '../../proto/livekit_models';
|
|
2
2
|
import type LocalAudioTrack from './LocalAudioTrack';
|
3
3
|
import type LocalTrack from './LocalTrack';
|
4
4
|
import type LocalVideoTrack from './LocalVideoTrack';
|
5
|
-
import type { TrackPublishOptions } from './options';
|
6
5
|
import type { Track } from './Track';
|
7
6
|
import { TrackPublication } from './TrackPublication';
|
7
|
+
import type { TrackPublishOptions } from './options';
|
8
8
|
export default class LocalTrackPublication extends TrackPublication {
|
9
9
|
track?: LocalTrack;
|
10
10
|
options?: TrackPublishOptions;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { AudioReceiverStats } from '../stats';
|
2
|
-
import type { AudioOutputOptions } from './options';
|
3
2
|
import RemoteTrack from './RemoteTrack';
|
3
|
+
import type { AudioOutputOptions } from './options';
|
4
4
|
export default class RemoteAudioTrack extends RemoteTrack {
|
5
5
|
private prevStats?;
|
6
6
|
private elementVolume;
|
@@ -22,4 +22,5 @@ export type LiveKitReactNativeInfo = {
|
|
22
22
|
platform: 'ios' | 'android' | 'windows' | 'macos' | 'web' | 'native';
|
23
23
|
devicePixelRatio: number;
|
24
24
|
};
|
25
|
+
export type SimulationScenario = 'signal-reconnect' | 'speaker' | 'node-failure' | 'server-leave' | 'migration' | 'resume-reconnect' | 'force-tcp' | 'force-tls' | 'full-reconnect';
|
25
26
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "livekit-client",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.9.0",
|
4
4
|
"description": "JavaScript/TypeScript client SDK for LiveKit",
|
5
5
|
"main": "./dist/livekit-client.umd.js",
|
6
6
|
"unpkg": "./dist/livekit-client.umd.js",
|
@@ -53,13 +53,14 @@
|
|
53
53
|
"devDependencies": {
|
54
54
|
"@babel/core": "7.21.4",
|
55
55
|
"@babel/preset-env": "7.21.4",
|
56
|
-
"@changesets/changelog-github": "0.4.8",
|
57
56
|
"@changesets/cli": "2.26.1",
|
57
|
+
"@livekit/changesets-changelog-github": "^0.0.4",
|
58
58
|
"@rollup/plugin-babel": "6.0.3",
|
59
59
|
"@rollup/plugin-commonjs": "24.1.0",
|
60
60
|
"@rollup/plugin-json": "6.0.0",
|
61
61
|
"@rollup/plugin-node-resolve": "15.0.2",
|
62
62
|
"@rollup/plugin-terser": "^0.4.0",
|
63
|
+
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
63
64
|
"@types/jest": "29.5.0",
|
64
65
|
"@types/sdp-transform": "2.4.6",
|
65
66
|
"@types/ua-parser-js": "0.7.36",
|
@@ -73,7 +74,7 @@
|
|
73
74
|
"eslint-plugin-import": "2.27.5",
|
74
75
|
"gh-pages": "5.0.0",
|
75
76
|
"jest": "29.5.0",
|
76
|
-
"prettier": "2.8.
|
77
|
+
"prettier": "^2.8.8",
|
77
78
|
"rollup": "3.20.2",
|
78
79
|
"rollup-plugin-delete": "^2.0.0",
|
79
80
|
"rollup-plugin-filesize": "10.0.0",
|
package/src/api/SignalClient.ts
CHANGED
@@ -33,7 +33,7 @@ import {
|
|
33
33
|
} from '../proto/livekit_rtc';
|
34
34
|
import { ConnectionError, ConnectionErrorReason } from '../room/errors';
|
35
35
|
import CriticalTimers from '../room/timers';
|
36
|
-
import { getClientInfo, isReactNative,
|
36
|
+
import { Mutex, getClientInfo, isReactNative, sleep } from '../room/utils';
|
37
37
|
|
38
38
|
// internal options
|
39
39
|
interface ConnectOpts {
|
@@ -374,7 +374,7 @@ export class SignalClient {
|
|
374
374
|
// answer a server-initiated offer
|
375
375
|
sendAnswer(answer: RTCSessionDescriptionInit) {
|
376
376
|
log.debug('sending answer');
|
377
|
-
this.sendRequest({
|
377
|
+
return this.sendRequest({
|
378
378
|
$case: 'answer',
|
379
379
|
answer: toProtoSessionDescription(answer),
|
380
380
|
});
|
@@ -382,7 +382,7 @@ export class SignalClient {
|
|
382
382
|
|
383
383
|
sendIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget) {
|
384
384
|
log.trace('sending ice candidate', candidate);
|
385
|
-
this.sendRequest({
|
385
|
+
return this.sendRequest({
|
386
386
|
$case: 'trickle',
|
387
387
|
trickle: {
|
388
388
|
candidateInit: JSON.stringify(candidate),
|
@@ -392,7 +392,7 @@ export class SignalClient {
|
|
392
392
|
}
|
393
393
|
|
394
394
|
sendMuteTrack(trackSid: string, muted: boolean) {
|
395
|
-
this.sendRequest({
|
395
|
+
return this.sendRequest({
|
396
396
|
$case: 'mute',
|
397
397
|
mute: {
|
398
398
|
sid: trackSid,
|
@@ -401,13 +401,23 @@ export class SignalClient {
|
|
401
401
|
});
|
402
402
|
}
|
403
403
|
|
404
|
-
sendAddTrack(req: AddTrackRequest)
|
405
|
-
this.sendRequest({
|
404
|
+
sendAddTrack(req: AddTrackRequest) {
|
405
|
+
return this.sendRequest({
|
406
406
|
$case: 'addTrack',
|
407
407
|
addTrack: AddTrackRequest.fromPartial(req),
|
408
408
|
});
|
409
409
|
}
|
410
410
|
|
411
|
+
sendUpdateLocalMetadata(metadata: string, name: string) {
|
412
|
+
return this.sendRequest({
|
413
|
+
$case: 'updateMetadata',
|
414
|
+
updateMetadata: {
|
415
|
+
metadata,
|
416
|
+
name,
|
417
|
+
},
|
418
|
+
});
|
419
|
+
}
|
420
|
+
|
411
421
|
sendUpdateTrackSettings(settings: UpdateTrackSettings) {
|
412
422
|
this.sendRequest({
|
413
423
|
$case: 'trackSetting',
|
@@ -416,21 +426,21 @@ export class SignalClient {
|
|
416
426
|
}
|
417
427
|
|
418
428
|
sendUpdateSubscription(sub: UpdateSubscription) {
|
419
|
-
this.sendRequest({
|
429
|
+
return this.sendRequest({
|
420
430
|
$case: 'subscription',
|
421
431
|
subscription: sub,
|
422
432
|
});
|
423
433
|
}
|
424
434
|
|
425
435
|
sendSyncState(sync: SyncState) {
|
426
|
-
this.sendRequest({
|
436
|
+
return this.sendRequest({
|
427
437
|
$case: 'syncState',
|
428
438
|
syncState: sync,
|
429
439
|
});
|
430
440
|
}
|
431
441
|
|
432
442
|
sendUpdateVideoLayers(trackSid: string, layers: VideoLayer[]) {
|
433
|
-
this.sendRequest({
|
443
|
+
return this.sendRequest({
|
434
444
|
$case: 'updateLayers',
|
435
445
|
updateLayers: {
|
436
446
|
trackSid,
|
@@ -440,7 +450,7 @@ export class SignalClient {
|
|
440
450
|
}
|
441
451
|
|
442
452
|
sendUpdateSubscriptionPermissions(allParticipants: boolean, trackPermissions: TrackPermission[]) {
|
443
|
-
this.sendRequest({
|
453
|
+
return this.sendRequest({
|
444
454
|
$case: 'subscriptionPermission',
|
445
455
|
subscriptionPermission: {
|
446
456
|
allParticipants,
|
@@ -450,7 +460,7 @@ export class SignalClient {
|
|
450
460
|
}
|
451
461
|
|
452
462
|
sendSimulateScenario(scenario: SimulateScenario) {
|
453
|
-
this.sendRequest({
|
463
|
+
return this.sendRequest({
|
454
464
|
$case: 'simulate',
|
455
465
|
simulate: scenario,
|
456
466
|
});
|
@@ -458,21 +468,23 @@ export class SignalClient {
|
|
458
468
|
|
459
469
|
sendPing() {
|
460
470
|
/** send both of ping and pingReq for compatibility to old and new server */
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
471
|
+
return Promise.all([
|
472
|
+
this.sendRequest({
|
473
|
+
$case: 'ping',
|
474
|
+
ping: Date.now(),
|
475
|
+
}),
|
476
|
+
this.sendRequest({
|
477
|
+
$case: 'pingReq',
|
478
|
+
pingReq: {
|
479
|
+
timestamp: Date.now(),
|
480
|
+
rtt: this.rtt,
|
481
|
+
},
|
482
|
+
}),
|
483
|
+
]);
|
484
|
+
}
|
485
|
+
|
486
|
+
sendLeave() {
|
487
|
+
return this.sendRequest({
|
476
488
|
$case: 'leave',
|
477
489
|
leave: {
|
478
490
|
canReconnect: false,
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import EventEmitter from 'events';
|
2
2
|
import type TypedEmitter from 'typed-emitter';
|
3
|
-
|
4
|
-
import { Checker, CheckInfo, CheckStatus, InstantiableCheck } from './checks/Checker';
|
3
|
+
import { CheckInfo, CheckStatus, Checker, InstantiableCheck } from './checks/Checker';
|
5
4
|
import { PublishAudioCheck } from './checks/publishAudio';
|
6
5
|
import { PublishVideoCheck } from './checks/publishVideo';
|
7
6
|
import { ReconnectCheck } from './checks/reconnect';
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { EventEmitter } from 'events';
|
2
2
|
import type TypedEmitter from 'typed-emitter';
|
3
3
|
import type { RoomConnectOptions, RoomOptions } from '../../options';
|
4
|
-
import Room, { ConnectionState } from '../../room/Room';
|
5
4
|
import type RTCEngine from '../../room/RTCEngine';
|
5
|
+
import Room, { ConnectionState } from '../../room/Room';
|
6
6
|
|
7
7
|
type LogMessage = {
|
8
8
|
level: 'info' | 'warning' | 'error';
|
package/src/index.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import { LogLevel, setLogExtension, setLogLevel } from './logger';
|
2
2
|
import { DataPacket_Kind, DisconnectReason, VideoQuality } from './proto/livekit_models';
|
3
3
|
import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
|
4
|
+
import Room, { ConnectionState, RoomState } from './room/Room';
|
4
5
|
import LocalParticipant from './room/participant/LocalParticipant';
|
5
6
|
import Participant, { ConnectionQuality } from './room/participant/Participant';
|
6
7
|
import type { ParticipantTrackPermission } from './room/participant/ParticipantTrackPermission';
|
7
8
|
import RemoteParticipant from './room/participant/RemoteParticipant';
|
8
|
-
import
|
9
|
+
import CriticalTimers from './room/timers';
|
9
10
|
import LocalAudioTrack from './room/track/LocalAudioTrack';
|
10
11
|
import LocalTrack from './room/track/LocalTrack';
|
11
12
|
import LocalTrackPublication from './room/track/LocalTrackPublication';
|
@@ -13,27 +14,24 @@ import LocalVideoTrack from './room/track/LocalVideoTrack';
|
|
13
14
|
import RemoteAudioTrack from './room/track/RemoteAudioTrack';
|
14
15
|
import RemoteTrack from './room/track/RemoteTrack';
|
15
16
|
import RemoteTrackPublication from './room/track/RemoteTrackPublication';
|
16
|
-
import RemoteVideoTrack from './room/track/RemoteVideoTrack';
|
17
|
-
import type { ElementInfo } from './room/track/RemoteVideoTrack';
|
17
|
+
import RemoteVideoTrack, { type ElementInfo } from './room/track/RemoteVideoTrack';
|
18
18
|
import { TrackPublication } from './room/track/TrackPublication';
|
19
|
-
import
|
19
|
+
import type { LiveKitReactNativeInfo } from './room/types';
|
20
20
|
import {
|
21
|
+
type AudioAnalyserOptions,
|
22
|
+
createAudioAnalyser,
|
21
23
|
getEmptyAudioStreamTrack,
|
22
24
|
getEmptyVideoStreamTrack,
|
23
25
|
isBrowserSupported,
|
24
|
-
supportsAdaptiveStream,
|
25
26
|
supportsAV1,
|
27
|
+
supportsAdaptiveStream,
|
26
28
|
supportsDynacast,
|
27
|
-
createAudioAnalyser,
|
28
29
|
} from './room/utils';
|
29
30
|
|
30
|
-
import type { AudioAnalyserOptions } from './room/utils';
|
31
|
-
import type { LiveKitReactNativeInfo } from './room/types';
|
32
|
-
|
33
31
|
export * from './options';
|
34
32
|
export * from './room/errors';
|
35
33
|
export * from './room/events';
|
36
|
-
export type { DataPublishOptions } from './room/types';
|
34
|
+
export type { DataPublishOptions, SimulationScenario } from './room/types';
|
37
35
|
export * from './room/track/create';
|
38
36
|
export * from './room/track/options';
|
39
37
|
export * from './room/track/Track';
|
@@ -438,6 +438,7 @@ export interface Room {
|
|
438
438
|
enabledCodecs: Codec[];
|
439
439
|
metadata: string;
|
440
440
|
numParticipants: number;
|
441
|
+
numPublishers: number;
|
441
442
|
activeRecording: boolean;
|
442
443
|
}
|
443
444
|
|
@@ -904,6 +905,7 @@ function createBaseRoom(): Room {
|
|
904
905
|
enabledCodecs: [],
|
905
906
|
metadata: "",
|
906
907
|
numParticipants: 0,
|
908
|
+
numPublishers: 0,
|
907
909
|
activeRecording: false,
|
908
910
|
};
|
909
911
|
}
|
@@ -937,6 +939,9 @@ export const Room = {
|
|
937
939
|
if (message.numParticipants !== 0) {
|
938
940
|
writer.uint32(72).uint32(message.numParticipants);
|
939
941
|
}
|
942
|
+
if (message.numPublishers !== 0) {
|
943
|
+
writer.uint32(88).uint32(message.numPublishers);
|
944
|
+
}
|
940
945
|
if (message.activeRecording === true) {
|
941
946
|
writer.uint32(80).bool(message.activeRecording);
|
942
947
|
}
|
@@ -1013,6 +1018,13 @@ export const Room = {
|
|
1013
1018
|
|
1014
1019
|
message.numParticipants = reader.uint32();
|
1015
1020
|
continue;
|
1021
|
+
case 11:
|
1022
|
+
if (tag != 88) {
|
1023
|
+
break;
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
message.numPublishers = reader.uint32();
|
1027
|
+
continue;
|
1016
1028
|
case 10:
|
1017
1029
|
if (tag != 80) {
|
1018
1030
|
break;
|
@@ -1042,6 +1054,7 @@ export const Room = {
|
|
1042
1054
|
: [],
|
1043
1055
|
metadata: isSet(object.metadata) ? String(object.metadata) : "",
|
1044
1056
|
numParticipants: isSet(object.numParticipants) ? Number(object.numParticipants) : 0,
|
1057
|
+
numPublishers: isSet(object.numPublishers) ? Number(object.numPublishers) : 0,
|
1045
1058
|
activeRecording: isSet(object.activeRecording) ? Boolean(object.activeRecording) : false,
|
1046
1059
|
};
|
1047
1060
|
},
|
@@ -1061,6 +1074,7 @@ export const Room = {
|
|
1061
1074
|
}
|
1062
1075
|
message.metadata !== undefined && (obj.metadata = message.metadata);
|
1063
1076
|
message.numParticipants !== undefined && (obj.numParticipants = Math.round(message.numParticipants));
|
1077
|
+
message.numPublishers !== undefined && (obj.numPublishers = Math.round(message.numPublishers));
|
1064
1078
|
message.activeRecording !== undefined && (obj.activeRecording = message.activeRecording);
|
1065
1079
|
return obj;
|
1066
1080
|
},
|
@@ -1080,6 +1094,7 @@ export const Room = {
|
|
1080
1094
|
message.enabledCodecs = object.enabledCodecs?.map((e) => Codec.fromPartial(e)) || [];
|
1081
1095
|
message.metadata = object.metadata ?? "";
|
1082
1096
|
message.numParticipants = object.numParticipants ?? 0;
|
1097
|
+
message.numPublishers = object.numPublishers ?? 0;
|
1083
1098
|
message.activeRecording = object.activeRecording ?? false;
|
1084
1099
|
return message;
|
1085
1100
|
},
|
package/src/room/RTCEngine.ts
CHANGED
@@ -22,6 +22,9 @@ import {
|
|
22
22
|
SignalTarget,
|
23
23
|
TrackPublishedResponse,
|
24
24
|
} from '../proto/livekit_rtc';
|
25
|
+
import PCTransport, { PCEvents } from './PCTransport';
|
26
|
+
import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
|
27
|
+
import { RegionUrlProvider } from './RegionUrlProvider';
|
25
28
|
import { roomConnectOptionDefaults } from './defaults';
|
26
29
|
import {
|
27
30
|
ConnectionError,
|
@@ -31,24 +34,21 @@ import {
|
|
31
34
|
UnexpectedConnectionState,
|
32
35
|
} from './errors';
|
33
36
|
import { EngineEvent } from './events';
|
34
|
-
import PCTransport, { PCEvents } from './PCTransport';
|
35
|
-
import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
|
36
37
|
import CriticalTimers from './timers';
|
37
38
|
import type LocalTrack from './track/LocalTrack';
|
38
39
|
import type LocalVideoTrack from './track/LocalVideoTrack';
|
39
40
|
import type { SimulcastTrackInfo } from './track/LocalVideoTrack';
|
40
|
-
import type { TrackPublishOptions, VideoCodec } from './track/options';
|
41
41
|
import { Track } from './track/Track';
|
42
|
+
import type { TrackPublishOptions, VideoCodec } from './track/options';
|
42
43
|
import {
|
44
|
+
Mutex,
|
43
45
|
isCloud,
|
44
46
|
isWeb,
|
45
|
-
Mutex,
|
46
47
|
sleep,
|
47
48
|
supportsAddTrack,
|
48
49
|
supportsSetCodecPreferences,
|
49
50
|
supportsTransceiver,
|
50
51
|
} from './utils';
|
51
|
-
import { RegionUrlProvider } from './RegionUrlProvider';
|
52
52
|
|
53
53
|
const lossyDataChannel = '_lossy';
|
54
54
|
const reliableDataChannel = '_reliable';
|
@@ -75,6 +75,8 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
75
75
|
|
76
76
|
peerConnectionTimeout: number = roomConnectOptionDefaults.peerConnectionTimeout;
|
77
77
|
|
78
|
+
fullReconnectOnNext: boolean = false;
|
79
|
+
|
78
80
|
get isClosed() {
|
79
81
|
return this._isClosed;
|
80
82
|
}
|
@@ -118,8 +120,6 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
118
120
|
|
119
121
|
private reconnectStart: number = 0;
|
120
122
|
|
121
|
-
private fullReconnectOnNext: boolean = false;
|
122
|
-
|
123
123
|
private clientConfiguration?: ClientConfiguration;
|
124
124
|
|
125
125
|
private attemptingReconnect: boolean = false;
|
@@ -879,11 +879,13 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
879
879
|
throw new Error('simulated failure');
|
880
880
|
}
|
881
881
|
|
882
|
-
await this.waitForPCReconnected();
|
883
882
|
this.client.setReconnected();
|
883
|
+
this.emit(EngineEvent.SignalRestarted, joinResponse);
|
884
|
+
|
885
|
+
await this.waitForPCReconnected();
|
884
886
|
this.regionUrlProvider?.resetAttempts();
|
885
887
|
// reconnect success
|
886
|
-
this.emit(EngineEvent.Restarted
|
888
|
+
this.emit(EngineEvent.Restarted);
|
887
889
|
} catch (error) {
|
888
890
|
const nextRegionUrl = await this.regionUrlProvider?.getNextBestRegionUrl();
|
889
891
|
if (nextRegionUrl) {
|
@@ -992,7 +994,7 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
992
994
|
});
|
993
995
|
}
|
994
996
|
|
995
|
-
async waitForPCReconnected() {
|
997
|
+
private async waitForPCReconnected() {
|
996
998
|
const startTime = Date.now();
|
997
999
|
let now = startTime;
|
998
1000
|
this.pcState = PCState.Reconnecting;
|
@@ -1022,6 +1024,24 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
|
|
1022
1024
|
throw new ConnectionError('could not establish PC connection');
|
1023
1025
|
}
|
1024
1026
|
|
1027
|
+
waitForRestarted = () => {
|
1028
|
+
return new Promise<void>((resolve, reject) => {
|
1029
|
+
if (this.pcState === PCState.Connected) {
|
1030
|
+
resolve();
|
1031
|
+
}
|
1032
|
+
const onRestarted = () => {
|
1033
|
+
this.off(EngineEvent.Disconnected, onDisconnected);
|
1034
|
+
resolve();
|
1035
|
+
};
|
1036
|
+
const onDisconnected = () => {
|
1037
|
+
this.off(EngineEvent.Restarted, onRestarted);
|
1038
|
+
reject();
|
1039
|
+
};
|
1040
|
+
this.once(EngineEvent.Restarted, onRestarted);
|
1041
|
+
this.once(EngineEvent.Disconnected, onDisconnected);
|
1042
|
+
});
|
1043
|
+
};
|
1044
|
+
|
1025
1045
|
/* @internal */
|
1026
1046
|
async sendDataPacket(packet: DataPacket, kind: DataPacket_Kind) {
|
1027
1047
|
const msg = DataPacket.encode(packet).finish();
|
@@ -1246,8 +1266,9 @@ export type EngineEventCallbacks = {
|
|
1246
1266
|
resuming: () => void;
|
1247
1267
|
resumed: () => void;
|
1248
1268
|
restarting: () => void;
|
1249
|
-
restarted: (
|
1269
|
+
restarted: () => void;
|
1250
1270
|
signalResumed: () => void;
|
1271
|
+
signalRestarted: (joinResp: JoinResponse) => void;
|
1251
1272
|
closing: () => void;
|
1252
1273
|
mediaTrackAdded: (
|
1253
1274
|
track: MediaStreamTrack,
|
@@ -1,6 +1,6 @@
|
|
1
|
+
import log from '../logger';
|
1
2
|
import type { RegionInfo, RegionSettings } from '../proto/livekit_rtc';
|
2
3
|
import { ConnectionError, ConnectionErrorReason } from './errors';
|
3
|
-
import log from '../logger';
|
4
4
|
import { isCloud } from './utils';
|
5
5
|
|
6
6
|
export class RegionUrlProvider {
|