@vogent/vogent-web-client 0.1.3 → 0.1.4
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.
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room } from 'livekit-client';
|
|
2
1
|
import { VogentAudioConn } from './VogentDevice';
|
|
2
|
+
import { RemoteParticipant, RemoteTrack, RemoteTrackPublication, Room } from 'livekit-client';
|
|
3
3
|
export declare class LivekitCall {
|
|
4
4
|
_room: Room;
|
|
5
5
|
_params: any;
|
|
6
6
|
_handlers: {
|
|
7
|
-
ev: 'mute' | 'disconnect'
|
|
7
|
+
ev: 'mute' | 'disconnect';
|
|
8
8
|
fn: (...args: any[]) => void;
|
|
9
9
|
}[];
|
|
10
10
|
constructor(room: Room);
|
|
11
|
-
handleTrackSubscribed(track: RemoteTrack, _publication: RemoteTrackPublication, _participant: RemoteParticipant): void;
|
|
12
|
-
handleTrackUnsubscribed(track: RemoteTrack, _publication: RemoteTrackPublication, _participant: RemoteParticipant): void;
|
|
13
11
|
mute(status: boolean): void;
|
|
14
12
|
sendDigits(k: string): void;
|
|
15
13
|
disconnect(): void;
|
|
16
14
|
sendEvent(evName: string, ...args: any[]): void;
|
|
17
|
-
on(ev: 'mute' | 'disconnect'
|
|
15
|
+
on(ev: 'mute' | 'disconnect', fn: (...args: any[]) => void): void;
|
|
18
16
|
}
|
|
19
17
|
export declare class LivekitDevice {
|
|
20
18
|
_room: Room;
|
|
@@ -23,5 +21,7 @@ export declare class LivekitDevice {
|
|
|
23
21
|
private constructor();
|
|
24
22
|
static getDevice(sessionToken: string, url: string): Promise<LivekitDevice>;
|
|
25
23
|
disconnect(): void;
|
|
24
|
+
handleTrackSubscribed(track: RemoteTrack, _publication: RemoteTrackPublication, _participant: RemoteParticipant): void;
|
|
25
|
+
handleTrackUnsubscribed(track: RemoteTrack, _publication: RemoteTrackPublication, _participant: RemoteParticipant): void;
|
|
26
26
|
connect(_p: any): Promise<VogentAudioConn>;
|
|
27
27
|
}
|
|
@@ -4,28 +4,6 @@ export class LivekitCall {
|
|
|
4
4
|
this._room = room;
|
|
5
5
|
this._params = {};
|
|
6
6
|
this._handlers = [];
|
|
7
|
-
this._room
|
|
8
|
-
.on(RoomEvent.TrackSubscribed, (...args) => {
|
|
9
|
-
this.handleTrackSubscribed(...args);
|
|
10
|
-
})
|
|
11
|
-
.on(RoomEvent.TrackUnsubscribed, (...args) => this.handleTrackUnsubscribed(...args))
|
|
12
|
-
.on(RoomEvent.Disconnected, () => this.disconnect());
|
|
13
|
-
}
|
|
14
|
-
handleTrackSubscribed(track, _publication, _participant) {
|
|
15
|
-
console.log('Track subscribed', track);
|
|
16
|
-
if (track.kind === 'audio') {
|
|
17
|
-
const audioElement = track.attach();
|
|
18
|
-
document.body.appendChild(audioElement);
|
|
19
|
-
audioElement.style.display = 'none';
|
|
20
|
-
}
|
|
21
|
-
if (_participant.identity === 'livekit-ai-processor') {
|
|
22
|
-
this.sendEvent('track-added', track.mediaStreamTrack);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
handleTrackUnsubscribed(track, _publication, _participant) {
|
|
26
|
-
if (track.kind === 'audio') {
|
|
27
|
-
console.log('Track unsubscribed', track);
|
|
28
|
-
}
|
|
29
7
|
}
|
|
30
8
|
mute(status) {
|
|
31
9
|
if (status) {
|
|
@@ -70,6 +48,13 @@ export class LivekitDevice {
|
|
|
70
48
|
this._url = url;
|
|
71
49
|
// speeds up connection attempt
|
|
72
50
|
this._room.prepareConnection(this._url, this._token);
|
|
51
|
+
this._room
|
|
52
|
+
.on(RoomEvent.TrackSubscribed, this.handleTrackSubscribed)
|
|
53
|
+
.on(RoomEvent.TrackUnsubscribed, this.handleTrackUnsubscribed)
|
|
54
|
+
.on(RoomEvent.Disconnected, (reason) => {
|
|
55
|
+
console.log('Disconnected', reason);
|
|
56
|
+
this.disconnect();
|
|
57
|
+
});
|
|
73
58
|
}
|
|
74
59
|
static async getDevice(sessionToken, url) {
|
|
75
60
|
const room = new Room();
|
|
@@ -78,6 +63,19 @@ export class LivekitDevice {
|
|
|
78
63
|
disconnect() {
|
|
79
64
|
this._room.disconnect();
|
|
80
65
|
}
|
|
66
|
+
handleTrackSubscribed(track, _publication, _participant) {
|
|
67
|
+
console.log('Track subscribed', track);
|
|
68
|
+
if (track.kind === 'audio') {
|
|
69
|
+
const audioElement = track.attach();
|
|
70
|
+
document.body.appendChild(audioElement);
|
|
71
|
+
audioElement.style.display = 'none';
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
handleTrackUnsubscribed(track, _publication, _participant) {
|
|
75
|
+
if (track.kind === 'audio') {
|
|
76
|
+
console.log('Track unsubscribed', track);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
81
79
|
async connect(_p) {
|
|
82
80
|
await this._room.connect(this._url, this._token, {});
|
|
83
81
|
const lkcall = new LivekitCall(this._room);
|