We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<script setup lang="ts"> const configuration = { iceServers: [ { urls: 'stun:stun3.l.google.com:19302' } // STUN 服务器配置 ] }; let peer1: RTCPeerConnection let peer2: RTCPeerConnection onMounted(async ()=>{ peer1 = new RTCPeerConnection(configuration); peer1.onicecandidate = event => { console.log(event.candidate) if (event.candidate) { console.log('发送 ICE candidate: ', event.candidate); } }; peer1.onicecandidateerror=event=>{ console.log("onicecandidateerror",event) } peer2 = new RTCPeerConnection(configuration); peer2.onicecandidate = event => { console.log(event.candidate) if (event.candidate) { console.log('发送 ICE candidate: ', event.candidate); } }; peer2.onicecandidateerror=event=>{ console.log("onicecandidateerror",event) } const offer=await peer1.createOffer(); await peer1.setLocalDescription(offer); await peer2.setRemoteDescription(offer); const answer = await peer2.createAnswer(); await peer2.setLocalDescription(answer); await peer1.setRemoteDescription(answer); console.log(peer1.iceConnectionState) console.log(peer2.iceConnectionState) const dataChannel = peer1.createDataChannel("channel"); dataChannel.onopen = () => { console.log("Data channel is open"); // 定时发送消息 setInterval(() => { if (dataChannel.readyState === "open") { dataChannel.send("Hello from peer1!"); } }, 3000); // 每3秒发送一次消息 }; dataChannel.onmessage = event => { console.log("Message received by peer1: ", event.data); }; // 在 peer2 监听数据通道 peer2.ondatachannel = event => { const receivedChannel = event.channel; receivedChannel.onmessage = (event) => { console.log("Message received by peer2: ", event.data); }; }; }) </script> <template> <span></span> </template> <style scoped> </style>
The text was updated successfully, but these errors were encountered:
search stackoverflow, this has been explained many times. This repository is, as the template explains, not a place to get help with any webrtc issue.
Sorry, something went wrong.
No branches or pull requests
The text was updated successfully, but these errors were encountered: