chore: use peerjs stuff now

This commit is contained in:
2025-11-01 02:04:04 +01:00
parent 2aa36b433b
commit ebba9481c6
4 changed files with 12 additions and 143 deletions

View File

@@ -20,20 +20,12 @@ const { send } = useWebSocket(wsUrl, {
toast.success('stream joined successfully')
}
if (message.event === 'offer') {
let iceServers: RTCIceServer[] = [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
];
try {
const turnCredentials = await $fetch('/api/turn/credentials');
iceServers = turnCredentials as RTCIceServer[];
} catch (error) {
console.warn('Failed to fetch TURN credentials, using STUN only:', error);
}
const peerConnection = new RTCPeerConnection({
iceServers,
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" },
],
iceCandidatePoolSize: 10
});
viewerStore.setPeerConnection(peerConnection);

View File

@@ -23,20 +23,12 @@ const { send } = useWebSocket(wsUrl, {
}
if (message.event === 'viewer-joined') {
let iceServers: RTCIceServer[] = [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
];
try {
const turnCredentials = await $fetch('/api/turn/credentials');
iceServers = turnCredentials as RTCIceServer[];
} catch (error) {
console.warn('Failed to fetch TURN credentials, using STUN only:', error);
}
const peerConnection = new RTCPeerConnection({
iceServers,
iceServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: "turn:0.peerjs.com:3478", username: "peerjs", credential: "peerjsp" },
],
iceCandidatePoolSize: 10
});
streamerStore.addPeerConnection(message.viewerId, peerConnection)