Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LocalTrackSubscribed engine event #1222

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sixty-foxes-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Add internal LocalTrackSubscribed engine event
6 changes: 6 additions & 0 deletions src/api/SignalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ export class SignalClient {

onRequestResponse?: (response: RequestResponse) => void;

onLocalTrackSubscribed?: (trackSid: string) => void;

connectOptions?: ConnectOpts;

ws?: WebSocket;
Expand Down Expand Up @@ -743,6 +745,10 @@ export class SignalClient {
if (this.onRequestResponse) {
this.onRequestResponse(msg.value);
}
} else if (msg.case === 'trackSubscribed') {
if (this.onLocalTrackSubscribed) {
this.onLocalTrackSubscribed(msg.value.trackSid);
}
} else {
this.log.debug('unsupported message', { ...this.logContext, msgCase: msg.case });
}
Expand Down
5 changes: 5 additions & 0 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,10 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
this.emit(EngineEvent.LocalTrackUnpublished, response);
};

this.client.onLocalTrackSubscribed = (trackSid: string) => {
this.emit(EngineEvent.LocalTrackSubscribed, trackSid);
};

this.client.onTokenRefresh = (token: string) => {
this.token = token;
};
Expand Down Expand Up @@ -1413,6 +1417,7 @@ export type EngineEventCallbacks = {
subscriptionPermissionUpdate: (update: SubscriptionPermissionUpdate) => void;
subscribedQualityUpdate: (update: SubscribedQualityUpdate) => void;
localTrackUnpublished: (unpublishedResponse: TrackUnpublishedResponse) => void;
localTrackSubscribed: (trackSid: string) => void;
remoteMute: (trackSid: string, muted: boolean) => void;
offline: () => void;
signalRequestResponse: (response: RequestResponse) => void;
Expand Down
1 change: 1 addition & 0 deletions src/room/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ export enum EngineEvent {
RemoteMute = 'remoteMute',
SubscribedQualityUpdate = 'subscribedQualityUpdate',
LocalTrackUnpublished = 'localTrackUnpublished',
LocalTrackSubscribed = 'localTrackSubscribed',
Offline = 'offline',
SignalRequestResponse = 'signalRequestResponse',
}
Expand Down
Loading