implemented remote streames logic
Signed-off-by: heyhiru <hirentimbadiya74@gmail.com>
Este commit está contenido en:
39
client/src/service/peer.js
Archivo normal
39
client/src/service/peer.js
Archivo normal
@@ -0,0 +1,39 @@
|
||||
class PeerService {
|
||||
constructor() {
|
||||
if (!this.peer) {
|
||||
this.peer = new RTCPeerConnection({
|
||||
iceServers: [{
|
||||
urls: [
|
||||
"stun:stun.l.google.com:19302",
|
||||
"stun:global.stun.twilio.com:3478",
|
||||
]
|
||||
}]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
setLocalDescription = async (ans) => {
|
||||
if(this.peer){
|
||||
await this.peer.setRemoteDescription(new RTCSessionDescription(ans));
|
||||
}
|
||||
}
|
||||
|
||||
getAnswer = async (offer) => {
|
||||
if(this.peer){
|
||||
await this.peer.setRemoteDescription(offer);
|
||||
const ans = await this.peer.createAnswer();
|
||||
await this.peer.setLocalDescription(new RTCSessionDescription(ans));
|
||||
return ans;
|
||||
}
|
||||
}
|
||||
|
||||
getOffer = async () => {
|
||||
if (this.peer) {
|
||||
const offer = await this.peer.createOffer();
|
||||
await this.peer.setLocalDescription(new RTCSessionDescription(offer));
|
||||
return offer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new PeerService();
|
||||
Referencia en una nueva incidencia
Block a user