@vogent/vogent-web-client 0.1.0 → 0.1.1

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.
@@ -4,15 +4,17 @@ export declare class LivekitCall {
4
4
  _room: Room;
5
5
  _params: any;
6
6
  _handlers: {
7
- ev: 'mute' | 'disconnect';
7
+ ev: 'mute' | 'disconnect' | 'track-added';
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;
11
13
  mute(status: boolean): void;
12
14
  sendDigits(k: string): void;
13
15
  disconnect(): void;
14
16
  sendEvent(evName: string, ...args: any[]): void;
15
- on(ev: 'mute' | 'disconnect', fn: (...args: any[]) => void): void;
17
+ on(ev: 'mute' | 'disconnect' | 'track-added', fn: (...args: any[]) => void): void;
16
18
  }
17
19
  export declare class LivekitDevice {
18
20
  _room: Room;
@@ -21,7 +23,5 @@ export declare class LivekitDevice {
21
23
  private constructor();
22
24
  static getDevice(sessionToken: string, url: string): Promise<LivekitDevice>;
23
25
  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,6 +4,28 @@ 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
+ }
7
29
  }
8
30
  mute(status) {
9
31
  if (status) {
@@ -48,10 +70,6 @@ export class LivekitDevice {
48
70
  this._url = url;
49
71
  // speeds up connection attempt
50
72
  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, this.disconnect);
55
73
  }
56
74
  static async getDevice(sessionToken, url) {
57
75
  const room = new Room();
@@ -60,18 +78,6 @@ export class LivekitDevice {
60
78
  disconnect() {
61
79
  this._room.disconnect();
62
80
  }
63
- handleTrackSubscribed(track, _publication, _participant) {
64
- if (track.kind === 'audio') {
65
- const audioElement = track.attach();
66
- document.body.appendChild(audioElement);
67
- audioElement.style.display = 'none';
68
- }
69
- }
70
- handleTrackUnsubscribed(track, _publication, _participant) {
71
- if (track.kind === 'audio') {
72
- console.log('Track unsubscribed', track);
73
- }
74
- }
75
81
  async connect(_p) {
76
82
  await this._room.connect(this._url, this._token, {});
77
83
  const lkcall = new LivekitCall(this._room);
@@ -10,7 +10,7 @@ export interface VogentAudioConn {
10
10
  * - 'disconnect': Fired when the connection is terminated
11
11
  * @param fn - Callback function to handle the event
12
12
  */
13
- on: (ev: 'mute' | 'disconnect', fn: (...args: any[]) => void) => void;
13
+ on: (ev: 'mute' | 'disconnect' | 'track-added', fn: (...args: any[]) => void) => void;
14
14
  /**
15
15
  * Mute or unmute the audio connection
16
16
  * @param status - True to mute, false to unmute
@@ -6,7 +6,7 @@ export declare class VonageCall {
6
6
  _liveListen: boolean;
7
7
  _params: any;
8
8
  _handlers: {
9
- ev: 'mute' | 'disconnect';
9
+ ev: 'mute' | 'disconnect' | 'track-added';
10
10
  fn: (...args: any[]) => void;
11
11
  }[];
12
12
  constructor(callId: string, client: VonageClient, params: any);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vogent/vogent-web-client",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "dependencies": {
6
6
  "@apollo/client": "^3.12.4",