@livekit/rtc-node 0.12.1 → 0.13.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/audio_frame.cjs +2 -2
- package/dist/audio_frame.cjs.map +1 -1
- package/dist/audio_frame.d.cts +31 -0
- package/dist/audio_frame.d.ts +11 -5
- package/dist/audio_frame.d.ts.map +1 -1
- package/dist/audio_frame.js +3 -3
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_resampler.cjs +10 -7
- package/dist/audio_resampler.cjs.map +1 -1
- package/dist/audio_resampler.d.cts +59 -0
- package/dist/audio_resampler.d.ts +11 -3
- package/dist/audio_resampler.d.ts.map +1 -1
- package/dist/audio_resampler.js +13 -10
- package/dist/audio_resampler.js.map +1 -1
- package/dist/audio_source.cjs +6 -4
- package/dist/audio_source.cjs.map +1 -1
- package/dist/audio_source.d.cts +37 -0
- package/dist/audio_source.d.ts +13 -5
- package/dist/audio_source.d.ts.map +1 -1
- package/dist/audio_source.js +9 -7
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.cjs +1 -2
- package/dist/audio_stream.cjs.map +1 -1
- package/dist/audio_stream.d.cts +37 -0
- package/dist/audio_stream.d.ts +16 -5
- package/dist/audio_stream.d.ts.map +1 -1
- package/dist/audio_stream.js +2 -3
- package/dist/audio_stream.js.map +1 -1
- package/dist/e2ee.cjs +19 -20
- package/dist/e2ee.cjs.map +1 -1
- package/dist/e2ee.d.cts +47 -0
- package/dist/e2ee.d.ts +11 -8
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +29 -30
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.cjs +6 -5
- package/dist/ffi_client.cjs.map +1 -1
- package/dist/ffi_client.d.cts +35 -0
- package/dist/ffi_client.d.ts +23 -11
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +6 -10
- package/dist/ffi_client.js.map +1 -1
- package/dist/index.cjs +16 -49
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +20 -41
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -46
- package/dist/index.js.map +1 -1
- package/dist/napi/native.d.cjs.map +1 -1
- package/dist/napi/native.d.d.cts +21 -0
- package/dist/napi/native.d.d.ts +21 -0
- package/dist/napi/native.d.ts +5 -5
- package/dist/native.d.ts +5 -5
- package/dist/participant.cjs +57 -34
- package/dist/participant.cjs.map +1 -1
- package/dist/participant.d.cts +126 -0
- package/dist/participant.d.ts +34 -20
- package/dist/participant.d.ts.map +1 -1
- package/dist/participant.js +75 -50
- package/dist/participant.js.map +1 -1
- package/dist/proto/audio_frame_pb.cjs +977 -125
- package/dist/proto/audio_frame_pb.cjs.map +1 -1
- package/dist/proto/audio_frame_pb.d.cts +898 -0
- package/dist/proto/audio_frame_pb.d.ts +506 -417
- package/dist/proto/audio_frame_pb.d.ts.map +1 -1
- package/dist/proto/audio_frame_pb.js +943 -85
- package/dist/proto/audio_frame_pb.js.map +1 -1
- package/dist/proto/e2ee_pb.cjs +700 -85
- package/dist/proto/e2ee_pb.cjs.map +1 -1
- package/dist/proto/e2ee_pb.d.cts +653 -0
- package/dist/proto/e2ee_pb.d.ts +333 -263
- package/dist/proto/e2ee_pb.d.ts.map +1 -1
- package/dist/proto/e2ee_pb.js +675 -57
- package/dist/proto/e2ee_pb.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +369 -36
- package/dist/proto/ffi_pb.cjs.map +1 -1
- package/dist/proto/ffi_pb.d.cts +898 -0
- package/dist/proto/ffi_pb.d.ts +164 -112
- package/dist/proto/ffi_pb.d.ts.map +1 -1
- package/dist/proto/ffi_pb.js +364 -29
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/handle_pb.cjs +27 -7
- package/dist/proto/handle_pb.cjs.map +1 -1
- package/dist/proto/handle_pb.d.cts +31 -0
- package/dist/proto/handle_pb.d.ts +15 -15
- package/dist/proto/handle_pb.d.ts.map +1 -1
- package/dist/proto/handle_pb.js +26 -5
- package/dist/proto/handle_pb.js.map +1 -1
- package/dist/proto/participant_pb.cjs +112 -15
- package/dist/proto/participant_pb.cjs.map +1 -1
- package/dist/proto/participant_pb.d.cts +181 -0
- package/dist/proto/participant_pb.d.ts +143 -53
- package/dist/proto/participant_pb.d.ts.map +1 -1
- package/dist/proto/participant_pb.js +109 -11
- package/dist/proto/participant_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +2693 -302
- package/dist/proto/room_pb.cjs.map +1 -1
- package/dist/proto/room_pb.d.cts +2475 -0
- package/dist/proto/room_pb.d.ts +1269 -864
- package/dist/proto/room_pb.d.ts.map +1 -1
- package/dist/proto/room_pb.js +2603 -210
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/rpc_pb.cjs +302 -37
- package/dist/proto/rpc_pb.cjs.map +1 -1
- package/dist/proto/rpc_pb.d.cts +267 -0
- package/dist/proto/rpc_pb.d.ts +140 -108
- package/dist/proto/rpc_pb.d.ts.map +1 -1
- package/dist/proto/rpc_pb.js +291 -25
- package/dist/proto/rpc_pb.js.map +1 -1
- package/dist/proto/stats_pb.cjs +1253 -139
- package/dist/proto/stats_pb.cjs.map +1 -1
- package/dist/proto/stats_pb.d.cts +1764 -0
- package/dist/proto/stats_pb.d.ts +806 -693
- package/dist/proto/stats_pb.d.ts.map +1 -1
- package/dist/proto/stats_pb.js +1216 -93
- package/dist/proto/stats_pb.js.map +1 -1
- package/dist/proto/track_pb.cjs +462 -64
- package/dist/proto/track_pb.cjs.map +1 -1
- package/dist/proto/track_pb.d.cts +434 -0
- package/dist/proto/track_pb.d.ts +254 -220
- package/dist/proto/track_pb.d.ts.map +1 -1
- package/dist/proto/track_pb.js +447 -45
- package/dist/proto/track_pb.js.map +1 -1
- package/dist/proto/track_publication_pb.cjs +130 -0
- package/dist/proto/track_publication_pb.cjs.map +1 -0
- package/dist/proto/track_publication_pb.d.cts +80 -0
- package/dist/proto/track_publication_pb.d.ts +80 -0
- package/dist/proto/track_publication_pb.d.ts.map +1 -0
- package/dist/proto/track_publication_pb.js +103 -0
- package/dist/proto/track_publication_pb.js.map +1 -0
- package/dist/proto/video_frame_pb.cjs +648 -88
- package/dist/proto/video_frame_pb.cjs.map +1 -1
- package/dist/proto/video_frame_pb.d.cts +660 -0
- package/dist/proto/video_frame_pb.d.ts +375 -328
- package/dist/proto/video_frame_pb.d.ts.map +1 -1
- package/dist/proto/video_frame_pb.js +626 -60
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +93 -125
- package/dist/room.cjs.map +1 -1
- package/dist/room.d.cts +123 -0
- package/dist/room.d.ts +37 -34
- package/dist/room.d.ts.map +1 -1
- package/dist/room.js +92 -122
- package/dist/room.js.map +1 -1
- package/dist/rpc.cjs.map +1 -1
- package/dist/rpc.d.cts +81 -0
- package/dist/rpc.d.ts +10 -7
- package/dist/rpc.js.map +1 -1
- package/dist/track.cjs +12 -8
- package/dist/track.cjs.map +1 -1
- package/dist/track.d.cts +45 -0
- package/dist/track.d.ts +30 -20
- package/dist/track.d.ts.map +1 -1
- package/dist/track.js +13 -9
- package/dist/track.js.map +1 -1
- package/dist/track_publication.cjs +21 -12
- package/dist/track_publication.cjs.map +1 -1
- package/dist/track_publication.d.cts +47 -0
- package/dist/track_publication.d.ts +30 -19
- package/dist/track_publication.d.ts.map +1 -1
- package/dist/track_publication.js +22 -13
- package/dist/track_publication.js.map +1 -1
- package/dist/transcription.d.cts +15 -0
- package/dist/transcription.d.ts +4 -3
- package/dist/types.d.cts +9 -0
- package/dist/types.d.ts +3 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +3 -0
- package/dist/version.d.ts +3 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +26 -45
- package/dist/video_frame.cjs.map +1 -1
- package/dist/video_frame.d.cts +24 -0
- package/dist/video_frame.d.ts +10 -4
- package/dist/video_frame.d.ts.map +1 -1
- package/dist/video_frame.js +29 -48
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.cjs +7 -4
- package/dist/video_source.cjs.map +1 -1
- package/dist/video_source.d.cts +22 -0
- package/dist/video_source.d.ts +14 -7
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +9 -6
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.cjs +16 -5
- package/dist/video_stream.cjs.map +1 -1
- package/dist/video_stream.d.cts +40 -0
- package/dist/video_stream.d.ts +18 -7
- package/dist/video_stream.d.ts.map +1 -1
- package/dist/video_stream.js +17 -6
- package/dist/video_stream.js.map +1 -1
- package/package.json +17 -12
- package/src/audio_frame.ts +10 -10
- package/src/audio_resampler.ts +15 -13
- package/src/audio_source.ts +11 -8
- package/src/audio_stream.ts +3 -4
- package/src/e2ee.ts +36 -37
- package/src/ffi_client.ts +8 -16
- package/src/index.ts +5 -68
- package/src/napi/native.d.ts +5 -5
- package/src/participant.ts +100 -72
- package/src/proto/audio_frame_pb.ts +1220 -496
- package/src/proto/e2ee_pb.ts +858 -337
- package/src/proto/ffi_pb.ts +442 -135
- package/src/proto/handle_pb.ts +33 -19
- package/src/proto/participant_pb.ts +225 -60
- package/src/proto/room_pb.ts +3149 -1013
- package/src/proto/rpc_pb.ts +358 -129
- package/src/proto/stats_pb.ts +1891 -877
- package/src/proto/track_pb.ts +587 -253
- package/src/proto/track_publication_pb.ts +180 -0
- package/src/proto/video_frame_pb.ts +861 -394
- package/src/room.ts +143 -188
- package/src/rpc.ts +1 -1
- package/src/track.ts +16 -17
- package/src/track_publication.ts +25 -26
- package/src/version.ts +1 -1
- package/src/video_frame.ts +48 -72
- package/src/video_source.ts +11 -8
- package/src/video_stream.ts +18 -8
package/src/napi/native.d.ts
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export function livekitInitialize(
|
|
7
7
|
callback: (data: Uint8Array) => void,
|
|
8
8
|
captureLogs: boolean,
|
|
9
9
|
sdkVersion: string,
|
|
10
10
|
): void;
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
11
|
+
export function livekitFfiRequest(data: Uint8Array): Uint8Array;
|
|
12
|
+
export function livekitRetrievePtr(handle: Uint8Array): bigint;
|
|
13
|
+
export function livekitCopyBuffer(ptr: bigint, len: number): Uint8Array;
|
|
14
|
+
export function livekitDispose(): Promise<void>;
|
|
15
15
|
export declare class FfiHandle {
|
|
16
16
|
constructor(handle: bigint);
|
|
17
17
|
dispose(): void;
|
package/src/participant.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2024 LiveKit, Inc.
|
|
2
2
|
//
|
|
3
3
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
-
import { create } from '@bufbuild/protobuf';
|
|
5
4
|
import { FfiClient, FfiHandle } from './ffi_client.js';
|
|
6
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
DisconnectReason,
|
|
7
|
+
type OwnedParticipant,
|
|
8
|
+
type ParticipantInfo,
|
|
9
|
+
type ParticipantKind,
|
|
10
|
+
} from './proto/participant_pb.js';
|
|
7
11
|
import type {
|
|
8
12
|
PublishDataCallback,
|
|
9
13
|
PublishDataResponse,
|
|
@@ -25,26 +29,20 @@ import type {
|
|
|
25
29
|
UnpublishTrackCallback,
|
|
26
30
|
UnpublishTrackResponse,
|
|
27
31
|
} from './proto/room_pb.js';
|
|
32
|
+
import { ChatMessage as ChatMessageModel } from './proto/room_pb.js';
|
|
28
33
|
import {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
EditChatMessageRequest,
|
|
35
|
+
TranscriptionSegment as ProtoTranscriptionSegment,
|
|
36
|
+
PublishDataRequest,
|
|
37
|
+
PublishSipDtmfRequest,
|
|
38
|
+
PublishTrackRequest,
|
|
39
|
+
PublishTranscriptionRequest,
|
|
40
|
+
SendChatMessageRequest,
|
|
41
|
+
SetLocalAttributesRequest,
|
|
42
|
+
SetLocalMetadataRequest,
|
|
43
|
+
SetLocalNameRequest,
|
|
44
|
+
UnpublishTrackRequest,
|
|
40
45
|
} from './proto/room_pb.js';
|
|
41
|
-
import { TranscriptionSegmentSchema } from './proto/room_pb.js';
|
|
42
|
-
import {
|
|
43
|
-
PerformRpcRequestSchema,
|
|
44
|
-
RegisterRpcMethodRequestSchema,
|
|
45
|
-
RpcMethodInvocationResponseRequestSchema,
|
|
46
|
-
UnregisterRpcMethodRequestSchema,
|
|
47
|
-
} from './proto/rpc_pb.js';
|
|
48
46
|
import type {
|
|
49
47
|
PerformRpcCallback,
|
|
50
48
|
PerformRpcResponse,
|
|
@@ -52,6 +50,12 @@ import type {
|
|
|
52
50
|
RpcMethodInvocationResponseResponse,
|
|
53
51
|
UnregisterRpcMethodResponse,
|
|
54
52
|
} from './proto/rpc_pb.js';
|
|
53
|
+
import {
|
|
54
|
+
PerformRpcRequest,
|
|
55
|
+
RegisterRpcMethodRequest,
|
|
56
|
+
RpcMethodInvocationResponseRequest,
|
|
57
|
+
UnregisterRpcMethodRequest,
|
|
58
|
+
} from './proto/rpc_pb.js';
|
|
55
59
|
import { type PerformRpcParams, RpcError, type RpcInvocationData } from './rpc.js';
|
|
56
60
|
import type { LocalTrack } from './track.js';
|
|
57
61
|
import type { RemoteTrackPublication, TrackPublication } from './track_publication.js';
|
|
@@ -69,33 +73,40 @@ export abstract class Participant {
|
|
|
69
73
|
trackPublications = new Map<string, TrackPublication>();
|
|
70
74
|
|
|
71
75
|
constructor(owned_info: OwnedParticipant) {
|
|
72
|
-
this.info = owned_info
|
|
73
|
-
this.ffi_handle = new FfiHandle(owned_info.handle!.id);
|
|
76
|
+
this.info = owned_info!.info!;
|
|
77
|
+
this.ffi_handle = new FfiHandle(owned_info.handle!.id!);
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
get sid(): string {
|
|
80
|
+
get sid(): string | undefined {
|
|
77
81
|
return this.info.sid;
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
get name(): string {
|
|
84
|
+
get name(): string | undefined {
|
|
81
85
|
return this.info.name;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
get identity(): string {
|
|
88
|
+
get identity(): string | undefined {
|
|
85
89
|
return this.info.identity;
|
|
86
90
|
}
|
|
87
91
|
|
|
88
|
-
get metadata(): string {
|
|
92
|
+
get metadata(): string | undefined {
|
|
89
93
|
return this.info.metadata;
|
|
90
94
|
}
|
|
91
95
|
|
|
92
|
-
get attributes(): Record<string, string> {
|
|
96
|
+
get attributes(): Record<string, string> | undefined {
|
|
93
97
|
return this.info.attributes;
|
|
94
98
|
}
|
|
95
99
|
|
|
96
|
-
get kind(): ParticipantKind {
|
|
100
|
+
get kind(): ParticipantKind | undefined {
|
|
97
101
|
return this.info.kind;
|
|
98
102
|
}
|
|
103
|
+
|
|
104
|
+
get disconnectReason(): DisconnectReason | undefined {
|
|
105
|
+
if (this.info.disconnectReason === DisconnectReason.UNKNOWN_REASON) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
return this.info.disconnectReason;
|
|
109
|
+
}
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
export type DataPublishOptions = {
|
|
@@ -120,7 +131,7 @@ export class LocalParticipant extends Participant {
|
|
|
120
131
|
trackPublications: Map<string, LocalTrackPublication> = new Map();
|
|
121
132
|
|
|
122
133
|
async publishData(data: Uint8Array, options: DataPublishOptions) {
|
|
123
|
-
const req =
|
|
134
|
+
const req = new PublishDataRequest({
|
|
124
135
|
localParticipantHandle: this.ffi_handle.handle,
|
|
125
136
|
dataPtr: FfiClient.instance.retrievePtr(data),
|
|
126
137
|
dataLen: BigInt(data.byteLength),
|
|
@@ -143,7 +154,7 @@ export class LocalParticipant extends Participant {
|
|
|
143
154
|
}
|
|
144
155
|
|
|
145
156
|
async publishDtmf(code: number, digit: string) {
|
|
146
|
-
const req =
|
|
157
|
+
const req = new PublishSipDtmfRequest({
|
|
147
158
|
localParticipantHandle: this.ffi_handle.handle,
|
|
148
159
|
code,
|
|
149
160
|
digit,
|
|
@@ -163,18 +174,19 @@ export class LocalParticipant extends Participant {
|
|
|
163
174
|
}
|
|
164
175
|
|
|
165
176
|
async publishTranscription(transcription: Transcription) {
|
|
166
|
-
const req =
|
|
177
|
+
const req = new PublishTranscriptionRequest({
|
|
167
178
|
localParticipantHandle: this.ffi_handle.handle,
|
|
168
179
|
participantIdentity: transcription.participantIdentity,
|
|
169
|
-
segments: transcription.segments.map(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
segments: transcription.segments.map(
|
|
181
|
+
(s) =>
|
|
182
|
+
new ProtoTranscriptionSegment({
|
|
183
|
+
id: s.id,
|
|
184
|
+
text: s.text,
|
|
185
|
+
startTime: s.startTime,
|
|
186
|
+
endTime: s.endTime,
|
|
187
|
+
final: s.final,
|
|
188
|
+
language: s.language,
|
|
189
|
+
}),
|
|
178
190
|
),
|
|
179
191
|
trackId: transcription.trackSid,
|
|
180
192
|
});
|
|
@@ -193,7 +205,7 @@ export class LocalParticipant extends Participant {
|
|
|
193
205
|
}
|
|
194
206
|
|
|
195
207
|
async updateMetadata(metadata: string) {
|
|
196
|
-
const req =
|
|
208
|
+
const req = new SetLocalMetadataRequest({
|
|
197
209
|
localParticipantHandle: this.ffi_handle.handle,
|
|
198
210
|
metadata: metadata,
|
|
199
211
|
});
|
|
@@ -220,7 +232,7 @@ export class LocalParticipant extends Participant {
|
|
|
220
232
|
destinationIdentities?: Array<string>,
|
|
221
233
|
senderIdentity?: string,
|
|
222
234
|
): Promise<ChatMessage> {
|
|
223
|
-
const req =
|
|
235
|
+
const req = new SendChatMessageRequest({
|
|
224
236
|
localParticipantHandle: this.ffi_handle.handle,
|
|
225
237
|
message: text,
|
|
226
238
|
destinationIdentities,
|
|
@@ -235,11 +247,19 @@ export class LocalParticipant extends Participant {
|
|
|
235
247
|
return ev.message.case == 'chatMessage' && ev.message.value.asyncId == res.asyncId;
|
|
236
248
|
});
|
|
237
249
|
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
switch (cb.message.case) {
|
|
251
|
+
case 'chatMessage':
|
|
252
|
+
const { id, timestamp, editTimestamp, message } = cb.message.value!;
|
|
253
|
+
return {
|
|
254
|
+
id: id!,
|
|
255
|
+
timestamp: Number(timestamp),
|
|
256
|
+
editTimestamp: Number(editTimestamp),
|
|
257
|
+
message: message!,
|
|
258
|
+
};
|
|
259
|
+
case 'error':
|
|
260
|
+
default:
|
|
261
|
+
throw new Error(cb.message.value);
|
|
240
262
|
}
|
|
241
|
-
const { id, timestamp, editTimestamp, message } = cb.message.value;
|
|
242
|
-
return { id, timestamp: Number(timestamp), editTimestamp: Number(editTimestamp), message };
|
|
243
263
|
}
|
|
244
264
|
|
|
245
265
|
/**
|
|
@@ -251,10 +271,10 @@ export class LocalParticipant extends Participant {
|
|
|
251
271
|
destinationIdentities?: Array<string>,
|
|
252
272
|
senderIdentity?: string,
|
|
253
273
|
): Promise<ChatMessage> {
|
|
254
|
-
const req =
|
|
274
|
+
const req = new EditChatMessageRequest({
|
|
255
275
|
localParticipantHandle: this.ffi_handle.handle,
|
|
256
276
|
editText,
|
|
257
|
-
originalMessage:
|
|
277
|
+
originalMessage: new ChatMessageModel({
|
|
258
278
|
...originalMessage,
|
|
259
279
|
timestamp: BigInt(originalMessage.timestamp),
|
|
260
280
|
editTimestamp: originalMessage.editTimestamp
|
|
@@ -273,15 +293,23 @@ export class LocalParticipant extends Participant {
|
|
|
273
293
|
return ev.message.case == 'chatMessage' && ev.message.value.asyncId == res.asyncId;
|
|
274
294
|
});
|
|
275
295
|
|
|
276
|
-
|
|
277
|
-
|
|
296
|
+
switch (cb.message.case) {
|
|
297
|
+
case 'chatMessage':
|
|
298
|
+
const { id, timestamp, editTimestamp, message } = cb.message.value!;
|
|
299
|
+
return {
|
|
300
|
+
id: id!,
|
|
301
|
+
timestamp: Number(timestamp),
|
|
302
|
+
editTimestamp: Number(editTimestamp),
|
|
303
|
+
message: message!,
|
|
304
|
+
};
|
|
305
|
+
case 'error':
|
|
306
|
+
default:
|
|
307
|
+
throw new Error(cb.message.value);
|
|
278
308
|
}
|
|
279
|
-
const { id, timestamp, editTimestamp, message } = cb.message.value;
|
|
280
|
-
return { id, timestamp: Number(timestamp), editTimestamp: Number(editTimestamp), message };
|
|
281
309
|
}
|
|
282
310
|
|
|
283
311
|
async updateName(name: string) {
|
|
284
|
-
const req =
|
|
312
|
+
const req = new SetLocalNameRequest({
|
|
285
313
|
localParticipantHandle: this.ffi_handle.handle,
|
|
286
314
|
name: name,
|
|
287
315
|
});
|
|
@@ -296,11 +324,9 @@ export class LocalParticipant extends Participant {
|
|
|
296
324
|
}
|
|
297
325
|
|
|
298
326
|
async setAttributes(attributes: Record<string, string>) {
|
|
299
|
-
const req =
|
|
327
|
+
const req = new SetLocalAttributesRequest({
|
|
300
328
|
localParticipantHandle: this.ffi_handle.handle,
|
|
301
|
-
attributes:
|
|
302
|
-
return { key, value };
|
|
303
|
-
}),
|
|
329
|
+
attributes: Object.entries(attributes).map(([key, value]) => ({ key, value })),
|
|
304
330
|
});
|
|
305
331
|
|
|
306
332
|
const res = FfiClient.instance.request<SetLocalAttributesResponse>({
|
|
@@ -316,7 +342,7 @@ export class LocalParticipant extends Participant {
|
|
|
316
342
|
track: LocalTrack,
|
|
317
343
|
options: TrackPublishOptions,
|
|
318
344
|
): Promise<LocalTrackPublication> {
|
|
319
|
-
const req =
|
|
345
|
+
const req = new PublishTrackRequest({
|
|
320
346
|
localParticipantHandle: this.ffi_handle.handle,
|
|
321
347
|
trackHandle: track.ffi_handle.handle,
|
|
322
348
|
options: options,
|
|
@@ -330,19 +356,21 @@ export class LocalParticipant extends Participant {
|
|
|
330
356
|
return ev.message.case == 'publishTrack' && ev.message.value.asyncId == res.asyncId;
|
|
331
357
|
});
|
|
332
358
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
track_publication.track = track;
|
|
339
|
-
this.trackPublications.set(track_publication.sid, track_publication);
|
|
359
|
+
switch (cb.message.case) {
|
|
360
|
+
case 'publication':
|
|
361
|
+
const track_publication = new LocalTrackPublication(cb.message.value!);
|
|
362
|
+
track_publication.track = track;
|
|
363
|
+
this.trackPublications.set(track_publication.sid!, track_publication);
|
|
340
364
|
|
|
341
|
-
|
|
365
|
+
return track_publication;
|
|
366
|
+
case 'error':
|
|
367
|
+
default:
|
|
368
|
+
throw new Error(cb.message.value);
|
|
369
|
+
}
|
|
342
370
|
}
|
|
343
371
|
|
|
344
372
|
async unpublishTrack(trackSid: string) {
|
|
345
|
-
const req =
|
|
373
|
+
const req = new UnpublishTrackRequest({
|
|
346
374
|
localParticipantHandle: this.ffi_handle.handle,
|
|
347
375
|
trackSid: trackSid,
|
|
348
376
|
});
|
|
@@ -378,7 +406,7 @@ export class LocalParticipant extends Participant {
|
|
|
378
406
|
payload,
|
|
379
407
|
responseTimeout,
|
|
380
408
|
}: PerformRpcParams): Promise<string> {
|
|
381
|
-
const req =
|
|
409
|
+
const req = new PerformRpcRequest({
|
|
382
410
|
localParticipantHandle: this.ffi_handle.handle,
|
|
383
411
|
destinationIdentity,
|
|
384
412
|
method,
|
|
@@ -398,7 +426,7 @@ export class LocalParticipant extends Participant {
|
|
|
398
426
|
throw RpcError.fromProto(cb.error);
|
|
399
427
|
}
|
|
400
428
|
|
|
401
|
-
return cb.payload
|
|
429
|
+
return cb.payload!;
|
|
402
430
|
}
|
|
403
431
|
|
|
404
432
|
/**
|
|
@@ -432,7 +460,7 @@ export class LocalParticipant extends Participant {
|
|
|
432
460
|
registerRpcMethod(method: string, handler: (data: RpcInvocationData) => Promise<string>) {
|
|
433
461
|
this.rpcHandlers.set(method, handler);
|
|
434
462
|
|
|
435
|
-
const req =
|
|
463
|
+
const req = new RegisterRpcMethodRequest({
|
|
436
464
|
localParticipantHandle: this.ffi_handle.handle,
|
|
437
465
|
method,
|
|
438
466
|
});
|
|
@@ -450,7 +478,7 @@ export class LocalParticipant extends Participant {
|
|
|
450
478
|
unregisterRpcMethod(method: string) {
|
|
451
479
|
this.rpcHandlers.delete(method);
|
|
452
480
|
|
|
453
|
-
const req =
|
|
481
|
+
const req = new UnregisterRpcMethodRequest({
|
|
454
482
|
localParticipantHandle: this.ffi_handle.handle,
|
|
455
483
|
method,
|
|
456
484
|
});
|
|
@@ -492,7 +520,7 @@ export class LocalParticipant extends Participant {
|
|
|
492
520
|
}
|
|
493
521
|
}
|
|
494
522
|
|
|
495
|
-
const req =
|
|
523
|
+
const req = new RpcMethodInvocationResponseRequest({
|
|
496
524
|
localParticipantHandle: this.ffi_handle.handle,
|
|
497
525
|
invocationId,
|
|
498
526
|
error: responseError ? responseError.toProto() : undefined,
|