With some experimenting on WebRTC, I found that the ondatachannel callback takes a function, but I'm wondering if it's possible to use a method of a Typescript class instead. Can someone please assist me with this?
export class MainComponent implements onViewInit {
peerConnection = null;
onViewInit() {
this.peerConnection = new RTCPeerConnection();
this.peerConnection.ondatachannel = this.receiveChannelCallbackt;
}
onMessage(event):void {
console.log("test);
}
receiveChannelCallbackt(event) {
event.channel.onmessage= onMessage;
}