webrtc/public/test.html

78 lines
2.9 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>webRTC</title>
</head>
<body>
<div>
<h1>Entanglement</h1>
<p>同步</p>
</div>
<script type="module">
import Entanglement from './entanglement.js'
const entanglement = new Entanglement({
options: {
iceServers: [
{
urls: 'turn:satori.love:3478?transport=udp',
username: 'x-username',
credential: 'x-password'
},
{
urls: [
'stun:stun.1und1.de',
'stun:stun.callwithus.com',
'stun:stun.ekiga.net',
'stun:stun.fwdnet.net',
'stun:stun.fwdnet.net:3478',
'stun:stun.gmx.net',
'stun:stun.iptel.org',
'stun:stun.internetcalls.com',
'stun:stun.minisipserver.com',
'stun:stun.schlund.de',
'stun:stun.sipgate.net',
'stun:stun.sipgate.net:10000',
'stun:stun.softjoys.com',
'stun:stun.softjoys.com:3478',
'stun:stun.voip.aebc.com',
'stun:stun.voipbuster.com',
'stun:stun.voipstunt.com',
'stun:stun.voxgratia.org',
'stun:stun.wirlab.net',
'stun:stun.xten.com',
'stun:stunserver.org',
'stun:stun01.sipphone.com',
'stun:stun.zoiper.com'
]
}
],
iceCandidatePoolSize: 10, // 限制 ICE 候选者的数量
iceTransportPolicy: 'all', // 使用所有可用的候选者
bundlePolicy: 'balanced', // 每種類型的內容建立一個單獨的傳輸
}, server: {}
})
entanglement.set('json', {
users: { name: 'users', list: [{ name: 'satori' }] },
music: { name: 'music', list: [{ name: 'satori' }] },
image: { name: 'image', list: [{ name: 'satori' }] }
})
const store = entanglement.get('json')
await new Promise(resolve => setTimeout(resolve, 3000))
store.users.name = 'koishi'
const element = document.createElement('ul')
element.innerHTML = store.users.list.map(user => `<li>${user.name}</li>`).join('')
element.onclick = () => {
store.users.list.push({ name: 'koishi' })
}
document.body.appendChild(element)
//users.list.push({ name: 'koishi' })
</script>
</body>
</html>