Skip to content

Commit

Permalink
feat: listener onStreamChange
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalan7 committed Apr 4, 2021
1 parent 9602b78 commit 5a5a819
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/api/layers/listener.layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ declare global {
onStateChange: any;
onIncomingCall: any;
onAck: any;
onStreamChange: any;
}
}
const callonMessage = new callbackWile();
Expand Down Expand Up @@ -119,6 +120,10 @@ export class ListenerLayer extends ProfileLayer {
window.WAPI.onStateChange(window['onStateChange']);
window['onStateChange'].exposed = true;
}
if (!window['onStreamChange'].exposed) {
window.WAPI.onStreamChange(window['onStreamChange']);
window['onStreamChange'].exposed = true;
}
if (!window['onAddedToGroup'].exposed) {
window.WAPI.onAddedToGroup(window['onAddedToGroup']);
window['onAddedToGroup'].exposed = true;
Expand All @@ -143,6 +148,20 @@ export class ListenerLayer extends ProfileLayer {
.catch(() => {});
}

/**
* @returns Returns the current state of the connection
*/
public async onStreamChange(fn: (state: SocketStream) => void) {
this.listenerEmitter.on(ExposedFn.onStreamChange, (state: SocketStream) => {
fn(state);
});
return {
dispose: () => {
this.listenerEmitter.off(ExposedFn.onStreamChange, fn);
},
};
}

/**
* @event Listens to messages received
* @returns Observable stream of messages
Expand Down

0 comments on commit 5a5a819

Please sign in to comment.