@fishjam-cloud/ts-client 0.8.1 → 0.10.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/dist/index.d.mts +1308 -0
- package/dist/index.mjs +1 -0
- package/package.json +23 -33
- package/dist/src/FishjamClient.d.ts +0 -511
- package/dist/src/FishjamClient.js +0 -669
- package/dist/src/auth.d.ts +0 -3
- package/dist/src/auth.js +0 -8
- package/dist/src/connectEventsHandler.d.ts +0 -2
- package/dist/src/connectEventsHandler.js +0 -22
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.js +0 -3
- package/dist/src/protos/fishjam/peer_notifications.d.ts +0 -51
- package/dist/src/protos/fishjam/peer_notifications.js +0 -309
- package/dist/src/protos/index.d.ts +0 -1
- package/dist/src/protos/index.js +0 -1
- package/dist/src/reconnection.d.ts +0 -27
- package/dist/src/reconnection.js +0 -119
- package/dist/src/webrtc/CommandsQueue.d.ts +0 -23
- package/dist/src/webrtc/CommandsQueue.js +0 -87
- package/dist/src/webrtc/ConnectionManager.d.ts +0 -27
- package/dist/src/webrtc/ConnectionManager.js +0 -65
- package/dist/src/webrtc/bitrate.d.ts +0 -12
- package/dist/src/webrtc/bitrate.js +0 -12
- package/dist/src/webrtc/deferred.d.ts +0 -8
- package/dist/src/webrtc/deferred.js +0 -17
- package/dist/src/webrtc/index.d.ts +0 -3
- package/dist/src/webrtc/index.js +0 -1
- package/dist/src/webrtc/internal.d.ts +0 -26
- package/dist/src/webrtc/internal.js +0 -34
- package/dist/src/webrtc/mediaEvent.d.ts +0 -10
- package/dist/src/webrtc/mediaEvent.js +0 -16
- package/dist/src/webrtc/tracks/Local.d.ts +0 -50
- package/dist/src/webrtc/tracks/Local.js +0 -280
- package/dist/src/webrtc/tracks/LocalTrack.d.ts +0 -62
- package/dist/src/webrtc/tracks/LocalTrack.js +0 -225
- package/dist/src/webrtc/tracks/LocalTrackManager.d.ts +0 -38
- package/dist/src/webrtc/tracks/LocalTrackManager.js +0 -77
- package/dist/src/webrtc/tracks/Remote.d.ts +0 -38
- package/dist/src/webrtc/tracks/Remote.js +0 -200
- package/dist/src/webrtc/tracks/RemoteTrack.d.ts +0 -39
- package/dist/src/webrtc/tracks/RemoteTrack.js +0 -64
- package/dist/src/webrtc/tracks/TrackCommon.d.ts +0 -8
- package/dist/src/webrtc/tracks/TrackCommon.js +0 -1
- package/dist/src/webrtc/tracks/bandwidth.d.ts +0 -1
- package/dist/src/webrtc/tracks/bandwidth.js +0 -27
- package/dist/src/webrtc/tracks/encodings.d.ts +0 -1
- package/dist/src/webrtc/tracks/encodings.js +0 -5
- package/dist/src/webrtc/tracks/muteTrackUtils.d.ts +0 -3
- package/dist/src/webrtc/tracks/muteTrackUtils.js +0 -19
- package/dist/src/webrtc/tracks/transceivers.d.ts +0 -2
- package/dist/src/webrtc/tracks/transceivers.js +0 -91
- package/dist/src/webrtc/types.d.ts +0 -314
- package/dist/src/webrtc/types.js +0 -2
- package/dist/src/webrtc/voiceActivityDetection.d.ts +0 -2
- package/dist/src/webrtc/voiceActivityDetection.js +0 -2
- package/dist/src/webrtc/webRTCEndpoint.d.ts +0 -297
- package/dist/src/webrtc/webRTCEndpoint.js +0 -686
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export function connectEventsHandler(fishjamClient) {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
const onSuccess = () => {
|
|
4
|
-
clearCallbacks();
|
|
5
|
-
resolve();
|
|
6
|
-
};
|
|
7
|
-
const onError = () => {
|
|
8
|
-
clearCallbacks();
|
|
9
|
-
reject();
|
|
10
|
-
};
|
|
11
|
-
fishjamClient.on('joined', onSuccess);
|
|
12
|
-
fishjamClient.on('joinError', onError);
|
|
13
|
-
fishjamClient.on('authError', onError);
|
|
14
|
-
fishjamClient.on('socketError', onError);
|
|
15
|
-
const clearCallbacks = () => {
|
|
16
|
-
fishjamClient.removeListener('joined', onSuccess);
|
|
17
|
-
fishjamClient.removeListener('joinError', onError);
|
|
18
|
-
fishjamClient.removeListener('authError', onError);
|
|
19
|
-
fishjamClient.removeListener('socketError', onError);
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
}
|
package/dist/src/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export type { Peer, Component, ConnectConfig, CreateConfig, MessageEvents } from './FishjamClient';
|
|
2
|
-
export type { ReconnectConfig, ReconnectionStatus } from './reconnection';
|
|
3
|
-
export type { AuthErrorReason } from './auth.js';
|
|
4
|
-
export { isAuthError, AUTH_ERROR_REASONS } from './auth.js';
|
|
5
|
-
export { FishjamClient } from './FishjamClient';
|
|
6
|
-
export type { TrackBandwidthLimit, SimulcastBandwidthLimit, BandwidthLimit, WebRTCEndpointEvents, TrackContextEvents, Endpoint, SimulcastConfig, TrackContext, Encoding, VadStatus, EncodingReason, MetadataParser, } from './webrtc';
|
|
7
|
-
export * from './webrtc';
|
package/dist/src/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
-
export declare const protobufPackage = "fishjam";
|
|
3
|
-
/** Defines any type of message sent between FJ and a peer */
|
|
4
|
-
export interface PeerMessage {
|
|
5
|
-
authenticated?: PeerMessage_Authenticated | undefined;
|
|
6
|
-
authRequest?: PeerMessage_AuthRequest | undefined;
|
|
7
|
-
mediaEvent?: PeerMessage_MediaEvent | undefined;
|
|
8
|
-
rtcStatsReport?: PeerMessage_RTCStatsReport | undefined;
|
|
9
|
-
}
|
|
10
|
-
/** Response sent by FJ, confirming successfull authentication */
|
|
11
|
-
export interface PeerMessage_Authenticated {
|
|
12
|
-
}
|
|
13
|
-
/** Request sent by peer, to authenticate to FJ server */
|
|
14
|
-
export interface PeerMessage_AuthRequest {
|
|
15
|
-
token: string;
|
|
16
|
-
}
|
|
17
|
-
/** Any type of WebRTC messages passed betweend FJ and peer */
|
|
18
|
-
export interface PeerMessage_MediaEvent {
|
|
19
|
-
data: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* PeerConnection stats sent by peer
|
|
23
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/RTCStatsReport#the_statistic_types
|
|
24
|
-
*/
|
|
25
|
-
export interface PeerMessage_RTCStatsReport {
|
|
26
|
-
data: string;
|
|
27
|
-
}
|
|
28
|
-
export declare const PeerMessage: MessageFns<PeerMessage>;
|
|
29
|
-
export declare const PeerMessage_Authenticated: MessageFns<PeerMessage_Authenticated>;
|
|
30
|
-
export declare const PeerMessage_AuthRequest: MessageFns<PeerMessage_AuthRequest>;
|
|
31
|
-
export declare const PeerMessage_MediaEvent: MessageFns<PeerMessage_MediaEvent>;
|
|
32
|
-
export declare const PeerMessage_RTCStatsReport: MessageFns<PeerMessage_RTCStatsReport>;
|
|
33
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
34
|
-
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
35
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
36
|
-
} : Partial<T>;
|
|
37
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
38
|
-
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
39
|
-
[K in keyof P]: Exact<P[K], I[K]>;
|
|
40
|
-
} & {
|
|
41
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
42
|
-
};
|
|
43
|
-
export interface MessageFns<T> {
|
|
44
|
-
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
45
|
-
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
46
|
-
fromJSON(object: any): T;
|
|
47
|
-
toJSON(message: T): unknown;
|
|
48
|
-
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
49
|
-
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
50
|
-
}
|
|
51
|
-
export {};
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
|
|
2
|
-
// versions:
|
|
3
|
-
// protoc-gen-ts_proto v2.2.3
|
|
4
|
-
// protoc v5.26.1
|
|
5
|
-
// source: protos/fishjam/peer_notifications.proto
|
|
6
|
-
/* eslint-disable */
|
|
7
|
-
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
8
|
-
export const protobufPackage = "fishjam";
|
|
9
|
-
function createBasePeerMessage() {
|
|
10
|
-
return { authenticated: undefined, authRequest: undefined, mediaEvent: undefined, rtcStatsReport: undefined };
|
|
11
|
-
}
|
|
12
|
-
export const PeerMessage = {
|
|
13
|
-
encode(message, writer = new BinaryWriter()) {
|
|
14
|
-
if (message.authenticated !== undefined) {
|
|
15
|
-
PeerMessage_Authenticated.encode(message.authenticated, writer.uint32(10).fork()).join();
|
|
16
|
-
}
|
|
17
|
-
if (message.authRequest !== undefined) {
|
|
18
|
-
PeerMessage_AuthRequest.encode(message.authRequest, writer.uint32(18).fork()).join();
|
|
19
|
-
}
|
|
20
|
-
if (message.mediaEvent !== undefined) {
|
|
21
|
-
PeerMessage_MediaEvent.encode(message.mediaEvent, writer.uint32(26).fork()).join();
|
|
22
|
-
}
|
|
23
|
-
if (message.rtcStatsReport !== undefined) {
|
|
24
|
-
PeerMessage_RTCStatsReport.encode(message.rtcStatsReport, writer.uint32(34).fork()).join();
|
|
25
|
-
}
|
|
26
|
-
return writer;
|
|
27
|
-
},
|
|
28
|
-
decode(input, length) {
|
|
29
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
30
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
31
|
-
const message = createBasePeerMessage();
|
|
32
|
-
while (reader.pos < end) {
|
|
33
|
-
const tag = reader.uint32();
|
|
34
|
-
switch (tag >>> 3) {
|
|
35
|
-
case 1: {
|
|
36
|
-
if (tag !== 10) {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
message.authenticated = PeerMessage_Authenticated.decode(reader, reader.uint32());
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
case 2: {
|
|
43
|
-
if (tag !== 18) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
message.authRequest = PeerMessage_AuthRequest.decode(reader, reader.uint32());
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
case 3: {
|
|
50
|
-
if (tag !== 26) {
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
message.mediaEvent = PeerMessage_MediaEvent.decode(reader, reader.uint32());
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
case 4: {
|
|
57
|
-
if (tag !== 34) {
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
message.rtcStatsReport = PeerMessage_RTCStatsReport.decode(reader, reader.uint32());
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
reader.skip(tag & 7);
|
|
68
|
-
}
|
|
69
|
-
return message;
|
|
70
|
-
},
|
|
71
|
-
fromJSON(object) {
|
|
72
|
-
return {
|
|
73
|
-
authenticated: isSet(object.authenticated) ? PeerMessage_Authenticated.fromJSON(object.authenticated) : undefined,
|
|
74
|
-
authRequest: isSet(object.authRequest) ? PeerMessage_AuthRequest.fromJSON(object.authRequest) : undefined,
|
|
75
|
-
mediaEvent: isSet(object.mediaEvent) ? PeerMessage_MediaEvent.fromJSON(object.mediaEvent) : undefined,
|
|
76
|
-
rtcStatsReport: isSet(object.rtcStatsReport)
|
|
77
|
-
? PeerMessage_RTCStatsReport.fromJSON(object.rtcStatsReport)
|
|
78
|
-
: undefined,
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
toJSON(message) {
|
|
82
|
-
const obj = {};
|
|
83
|
-
if (message.authenticated !== undefined) {
|
|
84
|
-
obj.authenticated = PeerMessage_Authenticated.toJSON(message.authenticated);
|
|
85
|
-
}
|
|
86
|
-
if (message.authRequest !== undefined) {
|
|
87
|
-
obj.authRequest = PeerMessage_AuthRequest.toJSON(message.authRequest);
|
|
88
|
-
}
|
|
89
|
-
if (message.mediaEvent !== undefined) {
|
|
90
|
-
obj.mediaEvent = PeerMessage_MediaEvent.toJSON(message.mediaEvent);
|
|
91
|
-
}
|
|
92
|
-
if (message.rtcStatsReport !== undefined) {
|
|
93
|
-
obj.rtcStatsReport = PeerMessage_RTCStatsReport.toJSON(message.rtcStatsReport);
|
|
94
|
-
}
|
|
95
|
-
return obj;
|
|
96
|
-
},
|
|
97
|
-
create(base) {
|
|
98
|
-
return PeerMessage.fromPartial(base ?? {});
|
|
99
|
-
},
|
|
100
|
-
fromPartial(object) {
|
|
101
|
-
const message = createBasePeerMessage();
|
|
102
|
-
message.authenticated = (object.authenticated !== undefined && object.authenticated !== null)
|
|
103
|
-
? PeerMessage_Authenticated.fromPartial(object.authenticated)
|
|
104
|
-
: undefined;
|
|
105
|
-
message.authRequest = (object.authRequest !== undefined && object.authRequest !== null)
|
|
106
|
-
? PeerMessage_AuthRequest.fromPartial(object.authRequest)
|
|
107
|
-
: undefined;
|
|
108
|
-
message.mediaEvent = (object.mediaEvent !== undefined && object.mediaEvent !== null)
|
|
109
|
-
? PeerMessage_MediaEvent.fromPartial(object.mediaEvent)
|
|
110
|
-
: undefined;
|
|
111
|
-
message.rtcStatsReport = (object.rtcStatsReport !== undefined && object.rtcStatsReport !== null)
|
|
112
|
-
? PeerMessage_RTCStatsReport.fromPartial(object.rtcStatsReport)
|
|
113
|
-
: undefined;
|
|
114
|
-
return message;
|
|
115
|
-
},
|
|
116
|
-
};
|
|
117
|
-
function createBasePeerMessage_Authenticated() {
|
|
118
|
-
return {};
|
|
119
|
-
}
|
|
120
|
-
export const PeerMessage_Authenticated = {
|
|
121
|
-
encode(_, writer = new BinaryWriter()) {
|
|
122
|
-
return writer;
|
|
123
|
-
},
|
|
124
|
-
decode(input, length) {
|
|
125
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
126
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
127
|
-
const message = createBasePeerMessage_Authenticated();
|
|
128
|
-
while (reader.pos < end) {
|
|
129
|
-
const tag = reader.uint32();
|
|
130
|
-
switch (tag >>> 3) {
|
|
131
|
-
}
|
|
132
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
reader.skip(tag & 7);
|
|
136
|
-
}
|
|
137
|
-
return message;
|
|
138
|
-
},
|
|
139
|
-
fromJSON(_) {
|
|
140
|
-
return {};
|
|
141
|
-
},
|
|
142
|
-
toJSON(_) {
|
|
143
|
-
const obj = {};
|
|
144
|
-
return obj;
|
|
145
|
-
},
|
|
146
|
-
create(base) {
|
|
147
|
-
return PeerMessage_Authenticated.fromPartial(base ?? {});
|
|
148
|
-
},
|
|
149
|
-
fromPartial(_) {
|
|
150
|
-
const message = createBasePeerMessage_Authenticated();
|
|
151
|
-
return message;
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
function createBasePeerMessage_AuthRequest() {
|
|
155
|
-
return { token: "" };
|
|
156
|
-
}
|
|
157
|
-
export const PeerMessage_AuthRequest = {
|
|
158
|
-
encode(message, writer = new BinaryWriter()) {
|
|
159
|
-
if (message.token !== "") {
|
|
160
|
-
writer.uint32(10).string(message.token);
|
|
161
|
-
}
|
|
162
|
-
return writer;
|
|
163
|
-
},
|
|
164
|
-
decode(input, length) {
|
|
165
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
166
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
167
|
-
const message = createBasePeerMessage_AuthRequest();
|
|
168
|
-
while (reader.pos < end) {
|
|
169
|
-
const tag = reader.uint32();
|
|
170
|
-
switch (tag >>> 3) {
|
|
171
|
-
case 1: {
|
|
172
|
-
if (tag !== 10) {
|
|
173
|
-
break;
|
|
174
|
-
}
|
|
175
|
-
message.token = reader.string();
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
reader.skip(tag & 7);
|
|
183
|
-
}
|
|
184
|
-
return message;
|
|
185
|
-
},
|
|
186
|
-
fromJSON(object) {
|
|
187
|
-
return { token: isSet(object.token) ? globalThis.String(object.token) : "" };
|
|
188
|
-
},
|
|
189
|
-
toJSON(message) {
|
|
190
|
-
const obj = {};
|
|
191
|
-
if (message.token !== "") {
|
|
192
|
-
obj.token = message.token;
|
|
193
|
-
}
|
|
194
|
-
return obj;
|
|
195
|
-
},
|
|
196
|
-
create(base) {
|
|
197
|
-
return PeerMessage_AuthRequest.fromPartial(base ?? {});
|
|
198
|
-
},
|
|
199
|
-
fromPartial(object) {
|
|
200
|
-
const message = createBasePeerMessage_AuthRequest();
|
|
201
|
-
message.token = object.token ?? "";
|
|
202
|
-
return message;
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
function createBasePeerMessage_MediaEvent() {
|
|
206
|
-
return { data: "" };
|
|
207
|
-
}
|
|
208
|
-
export const PeerMessage_MediaEvent = {
|
|
209
|
-
encode(message, writer = new BinaryWriter()) {
|
|
210
|
-
if (message.data !== "") {
|
|
211
|
-
writer.uint32(10).string(message.data);
|
|
212
|
-
}
|
|
213
|
-
return writer;
|
|
214
|
-
},
|
|
215
|
-
decode(input, length) {
|
|
216
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
217
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
218
|
-
const message = createBasePeerMessage_MediaEvent();
|
|
219
|
-
while (reader.pos < end) {
|
|
220
|
-
const tag = reader.uint32();
|
|
221
|
-
switch (tag >>> 3) {
|
|
222
|
-
case 1: {
|
|
223
|
-
if (tag !== 10) {
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
message.data = reader.string();
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
reader.skip(tag & 7);
|
|
234
|
-
}
|
|
235
|
-
return message;
|
|
236
|
-
},
|
|
237
|
-
fromJSON(object) {
|
|
238
|
-
return { data: isSet(object.data) ? globalThis.String(object.data) : "" };
|
|
239
|
-
},
|
|
240
|
-
toJSON(message) {
|
|
241
|
-
const obj = {};
|
|
242
|
-
if (message.data !== "") {
|
|
243
|
-
obj.data = message.data;
|
|
244
|
-
}
|
|
245
|
-
return obj;
|
|
246
|
-
},
|
|
247
|
-
create(base) {
|
|
248
|
-
return PeerMessage_MediaEvent.fromPartial(base ?? {});
|
|
249
|
-
},
|
|
250
|
-
fromPartial(object) {
|
|
251
|
-
const message = createBasePeerMessage_MediaEvent();
|
|
252
|
-
message.data = object.data ?? "";
|
|
253
|
-
return message;
|
|
254
|
-
},
|
|
255
|
-
};
|
|
256
|
-
function createBasePeerMessage_RTCStatsReport() {
|
|
257
|
-
return { data: "" };
|
|
258
|
-
}
|
|
259
|
-
export const PeerMessage_RTCStatsReport = {
|
|
260
|
-
encode(message, writer = new BinaryWriter()) {
|
|
261
|
-
if (message.data !== "") {
|
|
262
|
-
writer.uint32(10).string(message.data);
|
|
263
|
-
}
|
|
264
|
-
return writer;
|
|
265
|
-
},
|
|
266
|
-
decode(input, length) {
|
|
267
|
-
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
268
|
-
let end = length === undefined ? reader.len : reader.pos + length;
|
|
269
|
-
const message = createBasePeerMessage_RTCStatsReport();
|
|
270
|
-
while (reader.pos < end) {
|
|
271
|
-
const tag = reader.uint32();
|
|
272
|
-
switch (tag >>> 3) {
|
|
273
|
-
case 1: {
|
|
274
|
-
if (tag !== 10) {
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
message.data = reader.string();
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
if ((tag & 7) === 4 || tag === 0) {
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
reader.skip(tag & 7);
|
|
285
|
-
}
|
|
286
|
-
return message;
|
|
287
|
-
},
|
|
288
|
-
fromJSON(object) {
|
|
289
|
-
return { data: isSet(object.data) ? globalThis.String(object.data) : "" };
|
|
290
|
-
},
|
|
291
|
-
toJSON(message) {
|
|
292
|
-
const obj = {};
|
|
293
|
-
if (message.data !== "") {
|
|
294
|
-
obj.data = message.data;
|
|
295
|
-
}
|
|
296
|
-
return obj;
|
|
297
|
-
},
|
|
298
|
-
create(base) {
|
|
299
|
-
return PeerMessage_RTCStatsReport.fromPartial(base ?? {});
|
|
300
|
-
},
|
|
301
|
-
fromPartial(object) {
|
|
302
|
-
const message = createBasePeerMessage_RTCStatsReport();
|
|
303
|
-
message.data = object.data ?? "";
|
|
304
|
-
return message;
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
function isSet(value) {
|
|
308
|
-
return value !== null && value !== undefined;
|
|
309
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './fishjam/peer_notifications';
|
package/dist/src/protos/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './fishjam/peer_notifications';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { FishjamClient } from './FishjamClient';
|
|
2
|
-
export type ReconnectionStatus = 'reconnecting' | 'idle' | 'error';
|
|
3
|
-
export type ReconnectConfig = {
|
|
4
|
-
maxAttempts?: number;
|
|
5
|
-
initialDelay?: number;
|
|
6
|
-
delay?: number;
|
|
7
|
-
addTracksOnReconnect?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare class ReconnectManager<PeerMetadata, TrackMetadata> {
|
|
10
|
-
private readonly reconnectConfig;
|
|
11
|
-
private readonly connect;
|
|
12
|
-
private readonly client;
|
|
13
|
-
private initialMetadata;
|
|
14
|
-
private reconnectAttempt;
|
|
15
|
-
private reconnectTimeoutId;
|
|
16
|
-
private status;
|
|
17
|
-
private lastLocalEndpoint;
|
|
18
|
-
private removeEventListeners;
|
|
19
|
-
constructor(client: FishjamClient<PeerMetadata, TrackMetadata>, connect: (metadata: PeerMetadata) => void, config?: ReconnectConfig | boolean);
|
|
20
|
-
isReconnecting(): boolean;
|
|
21
|
-
reset(initialMetadata: PeerMetadata): void;
|
|
22
|
-
private getLastPeerMetadata;
|
|
23
|
-
private reconnect;
|
|
24
|
-
handleReconnect(): Promise<void>;
|
|
25
|
-
cleanup(): void;
|
|
26
|
-
}
|
|
27
|
-
export declare const createReconnectConfig: (config?: ReconnectConfig | boolean) => Required<ReconnectConfig>;
|
package/dist/src/reconnection.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { isAuthError } from './auth';
|
|
2
|
-
const DISABLED_RECONNECT_CONFIG = {
|
|
3
|
-
maxAttempts: 0,
|
|
4
|
-
initialDelay: 0,
|
|
5
|
-
delay: 0,
|
|
6
|
-
addTracksOnReconnect: false,
|
|
7
|
-
};
|
|
8
|
-
const DEFAULT_RECONNECT_CONFIG = {
|
|
9
|
-
maxAttempts: 3,
|
|
10
|
-
initialDelay: 500,
|
|
11
|
-
delay: 500,
|
|
12
|
-
addTracksOnReconnect: true,
|
|
13
|
-
};
|
|
14
|
-
export class ReconnectManager {
|
|
15
|
-
reconnectConfig;
|
|
16
|
-
connect;
|
|
17
|
-
client;
|
|
18
|
-
initialMetadata = undefined;
|
|
19
|
-
reconnectAttempt = 0;
|
|
20
|
-
reconnectTimeoutId = null;
|
|
21
|
-
status = 'idle';
|
|
22
|
-
lastLocalEndpoint = null;
|
|
23
|
-
removeEventListeners = () => { };
|
|
24
|
-
constructor(client, connect, config) {
|
|
25
|
-
this.client = client;
|
|
26
|
-
this.connect = connect;
|
|
27
|
-
this.reconnectConfig = createReconnectConfig(config);
|
|
28
|
-
const onSocketError = () => {
|
|
29
|
-
this.reconnect();
|
|
30
|
-
};
|
|
31
|
-
this.client.on('socketError', onSocketError);
|
|
32
|
-
const onConnectionError = () => {
|
|
33
|
-
this.reconnect();
|
|
34
|
-
};
|
|
35
|
-
this.client.on('connectionError', onConnectionError);
|
|
36
|
-
const onSocketClose = (event) => {
|
|
37
|
-
if (isAuthError(event.reason))
|
|
38
|
-
return;
|
|
39
|
-
this.reconnect();
|
|
40
|
-
};
|
|
41
|
-
this.client.on('socketClose', onSocketClose);
|
|
42
|
-
const onAuthSuccess = () => {
|
|
43
|
-
this.reset(this.initialMetadata);
|
|
44
|
-
};
|
|
45
|
-
this.client.on('authSuccess', onAuthSuccess);
|
|
46
|
-
this.removeEventListeners = () => {
|
|
47
|
-
this.client.off('socketError', onSocketError);
|
|
48
|
-
this.client.off('connectionError', onConnectionError);
|
|
49
|
-
this.client.off('socketClose', onSocketClose);
|
|
50
|
-
this.client.off('authSuccess', onAuthSuccess);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
isReconnecting() {
|
|
54
|
-
return this.status === 'reconnecting';
|
|
55
|
-
}
|
|
56
|
-
reset(initialMetadata) {
|
|
57
|
-
this.initialMetadata = initialMetadata;
|
|
58
|
-
this.reconnectAttempt = 0;
|
|
59
|
-
if (this.reconnectTimeoutId)
|
|
60
|
-
clearTimeout(this.reconnectTimeoutId);
|
|
61
|
-
this.reconnectTimeoutId = null;
|
|
62
|
-
}
|
|
63
|
-
getLastPeerMetadata() {
|
|
64
|
-
return this.lastLocalEndpoint?.metadata?.peer;
|
|
65
|
-
}
|
|
66
|
-
reconnect() {
|
|
67
|
-
if (this.reconnectTimeoutId)
|
|
68
|
-
return;
|
|
69
|
-
if (this.reconnectAttempt >= this.reconnectConfig.maxAttempts) {
|
|
70
|
-
if (this.status === 'reconnecting') {
|
|
71
|
-
this.status = 'error';
|
|
72
|
-
this.client.emit('reconnectionRetriesLimitReached');
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
if (this.status !== 'reconnecting') {
|
|
77
|
-
this.status = 'reconnecting';
|
|
78
|
-
this.client.emit('reconnectionStarted');
|
|
79
|
-
this.lastLocalEndpoint = this.client.getLocalPeer() || null;
|
|
80
|
-
}
|
|
81
|
-
const timeout = this.reconnectConfig.initialDelay + this.reconnectAttempt * this.reconnectConfig.delay;
|
|
82
|
-
this.reconnectAttempt += 1;
|
|
83
|
-
this.reconnectTimeoutId = setTimeout(() => {
|
|
84
|
-
this.reconnectTimeoutId = null;
|
|
85
|
-
this.connect(this.getLastPeerMetadata() ?? this.initialMetadata);
|
|
86
|
-
}, timeout);
|
|
87
|
-
}
|
|
88
|
-
async handleReconnect() {
|
|
89
|
-
if (this.status !== 'reconnecting')
|
|
90
|
-
return;
|
|
91
|
-
if (this.lastLocalEndpoint && this.reconnectConfig.addTracksOnReconnect) {
|
|
92
|
-
for await (const element of this.lastLocalEndpoint.tracks) {
|
|
93
|
-
const [_, track] = element;
|
|
94
|
-
if (!track.track || track.track.readyState !== 'live')
|
|
95
|
-
return;
|
|
96
|
-
await this.client.addTrack(track.track, track.rawMetadata, track.simulcastConfig, track.maxBandwidth);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
this.lastLocalEndpoint = null;
|
|
100
|
-
this.status = 'idle';
|
|
101
|
-
this.client.emit('reconnected');
|
|
102
|
-
}
|
|
103
|
-
cleanup() {
|
|
104
|
-
this.removeEventListeners();
|
|
105
|
-
this.removeEventListeners = () => { };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
export const createReconnectConfig = (config) => {
|
|
109
|
-
if (!config)
|
|
110
|
-
return DISABLED_RECONNECT_CONFIG;
|
|
111
|
-
if (config === true)
|
|
112
|
-
return DEFAULT_RECONNECT_CONFIG;
|
|
113
|
-
return {
|
|
114
|
-
maxAttempts: config?.maxAttempts ?? DEFAULT_RECONNECT_CONFIG.maxAttempts,
|
|
115
|
-
initialDelay: config?.initialDelay ?? DEFAULT_RECONNECT_CONFIG.initialDelay,
|
|
116
|
-
delay: config?.delay ?? DEFAULT_RECONNECT_CONFIG.delay,
|
|
117
|
-
addTracksOnReconnect: config?.addTracksOnReconnect ?? DEFAULT_RECONNECT_CONFIG.addTracksOnReconnect,
|
|
118
|
-
};
|
|
119
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Deferred } from './deferred';
|
|
2
|
-
import type { LocalTrackManager } from './tracks/LocalTrackManager';
|
|
3
|
-
import type { ConnectionManager } from './ConnectionManager';
|
|
4
|
-
export type Command = {
|
|
5
|
-
handler: () => Promise<void>;
|
|
6
|
-
parse?: () => void;
|
|
7
|
-
resolutionNotifier: Deferred<void>;
|
|
8
|
-
resolve: 'after-renegotiation' | 'on-handler-resolve';
|
|
9
|
-
};
|
|
10
|
-
export declare class CommandsQueue<EndpointMetadata, TrackMetadata> {
|
|
11
|
-
private readonly localTrackManager;
|
|
12
|
-
private connection;
|
|
13
|
-
private clearConnectionCallbacks;
|
|
14
|
-
constructor(localTrackManager: LocalTrackManager<EndpointMetadata, TrackMetadata>);
|
|
15
|
-
initConnection: (connection: ConnectionManager) => void;
|
|
16
|
-
private commandsQueue;
|
|
17
|
-
private commandResolutionNotifier;
|
|
18
|
-
pushCommand: (command: Command) => void;
|
|
19
|
-
processNextCommand: () => void;
|
|
20
|
-
private handleCommand;
|
|
21
|
-
private resolvePreviousCommand;
|
|
22
|
-
cleanUp: () => void;
|
|
23
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
export class CommandsQueue {
|
|
2
|
-
localTrackManager;
|
|
3
|
-
connection = null;
|
|
4
|
-
clearConnectionCallbacks = null;
|
|
5
|
-
constructor(localTrackManager) {
|
|
6
|
-
this.localTrackManager = localTrackManager;
|
|
7
|
-
}
|
|
8
|
-
initConnection = (connection) => {
|
|
9
|
-
this.connection = connection;
|
|
10
|
-
const onSignalingStateChange = () => {
|
|
11
|
-
if (connection.getConnection().signalingState === 'stable') {
|
|
12
|
-
this.processNextCommand();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const onIceGatheringStateChange = () => {
|
|
16
|
-
if (connection.getConnection().iceGatheringState === 'complete') {
|
|
17
|
-
this.processNextCommand();
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
const onConnectionStateChange = () => {
|
|
21
|
-
if (connection.getConnection().connectionState === 'connected') {
|
|
22
|
-
this.processNextCommand();
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const onIceConnectionStateChange = () => {
|
|
26
|
-
if (connection.getConnection().iceConnectionState === 'connected') {
|
|
27
|
-
this.processNextCommand();
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this.clearConnectionCallbacks = () => {
|
|
31
|
-
connection.getConnection().removeEventListener('signalingstatechange', onSignalingStateChange);
|
|
32
|
-
connection.getConnection().removeEventListener('icegatheringstatechange', onIceGatheringStateChange);
|
|
33
|
-
connection.getConnection().removeEventListener('connectionstatechange', onConnectionStateChange);
|
|
34
|
-
connection.getConnection().removeEventListener('iceconnectionstatechange', onIceConnectionStateChange);
|
|
35
|
-
};
|
|
36
|
-
connection.getConnection().addEventListener('icegatheringstatechange', onIceConnectionStateChange);
|
|
37
|
-
connection.getConnection().addEventListener('connectionstatechange', onConnectionStateChange);
|
|
38
|
-
connection.getConnection().addEventListener('iceconnectionstatechange', onIceConnectionStateChange);
|
|
39
|
-
connection.getConnection().addEventListener('signalingstatechange', onSignalingStateChange);
|
|
40
|
-
};
|
|
41
|
-
commandsQueue = [];
|
|
42
|
-
commandResolutionNotifier = null;
|
|
43
|
-
pushCommand = (command) => {
|
|
44
|
-
this.commandsQueue.push(command);
|
|
45
|
-
this.processNextCommand();
|
|
46
|
-
};
|
|
47
|
-
processNextCommand = () => {
|
|
48
|
-
if (this.localTrackManager.isNegotiationInProgress())
|
|
49
|
-
return;
|
|
50
|
-
if (this.connection?.isConnectionUnstable())
|
|
51
|
-
return;
|
|
52
|
-
this.resolvePreviousCommand();
|
|
53
|
-
const command = this.commandsQueue.shift();
|
|
54
|
-
if (!command)
|
|
55
|
-
return;
|
|
56
|
-
this.commandResolutionNotifier = command.resolutionNotifier;
|
|
57
|
-
this.handleCommand(command);
|
|
58
|
-
};
|
|
59
|
-
handleCommand = async (command) => {
|
|
60
|
-
try {
|
|
61
|
-
command.parse?.();
|
|
62
|
-
const promise = command.handler();
|
|
63
|
-
if (command.resolve === 'on-handler-resolve') {
|
|
64
|
-
await promise;
|
|
65
|
-
this.resolvePreviousCommand();
|
|
66
|
-
this.processNextCommand();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
this.commandResolutionNotifier?.reject(error);
|
|
71
|
-
this.commandResolutionNotifier = null;
|
|
72
|
-
this.processNextCommand();
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
resolvePreviousCommand = () => {
|
|
76
|
-
if (!this.commandResolutionNotifier)
|
|
77
|
-
return;
|
|
78
|
-
this.commandResolutionNotifier.resolve();
|
|
79
|
-
this.commandResolutionNotifier = null;
|
|
80
|
-
};
|
|
81
|
-
cleanUp = () => {
|
|
82
|
-
this.commandResolutionNotifier?.reject('Disconnected');
|
|
83
|
-
this.commandResolutionNotifier = null;
|
|
84
|
-
this.commandsQueue = [];
|
|
85
|
-
this.clearConnectionCallbacks?.();
|
|
86
|
-
};
|
|
87
|
-
}
|