Added frontend folder structure.

This commit is contained in:
2025-02-22 12:54:00 +05:30
parent 8f13ac6d4b
commit 15593af2a9
60 changed files with 9080 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
class PeerService {
constructor() {
if (!this.peer) {
this.peer = new RTCPeerConnection({
iceServers: [
{
urls: [
"stun:stun.l.google.com:19302",
"stun:global.stun.twilio.com:3478",
],
},
],
});
}
}
async getAnswer(offer) {
if (this.peer) {
await this.peer.setRemoteDescription(offer);
const ans = await this.peer.createAnswer();
await this.peer.setLocalDescription(new RTCSessionDescription(ans));
return ans;
}
}
async setLocalDescription(ans) {
if (this.peer) {
await this.peer.setRemoteDescription(new RTCSessionDescription(ans));
}
}
async getOffer() {
if (this.peer) {
const offer = await this.peer.createOffer();
await this.peer.setLocalDescription(new RTCSessionDescription(offer));
return offer;
}
}
}
export default new PeerService();