Open
Description
When I leave component in which i have implemented socket.client.emit and visit that component again the emit event triggers twice if i do the same the emit event triggers three times and so on.
I am using it to implement webrtc and each time user visits that page emit event triggers that many times
Kindly Let me know how to solve this issue
i have tried this.$socket.client.off("created") but it doesn't seem to be working
Sample Code
methods: {
onOffer(offer) {
if (!this.creator) {
this.rtcPeerConnection = new RTCPeerConnection(this.iceServers);
this.rtcPeerConnection.onicecandidate = this.onIceCandidateFunction;
// this.rtcPeerConnection.ontrack = onTrackFunction;
this.rtcPeerConnection.addStream(this.userStream);
this.rtcPeerConnection.setRemoteDescription(offer);
this.rtcPeerConnection.createAnswer(
(answer) => {
this.rtcPeerConnection.setLocalDescription(answer);
this.$socket.client.emit("answer", answer, this.roomName);
console.log("answer")
},
(error) => {
console.log(error);
}
);
}
},
}
created(){
this.$socket.$subscribe("offer", (offer) => {
console.log("offer");
this.onOffer(offer);
});
}
the answer event is triggered as many times as many times the component is re-rendered
I have been stuck in this issue since long time kindle provide some guidence
Thanks in Advance
Metadata
Metadata
Assignees
Labels
No labels