webrtc/public/test.html

94 lines
4.0 KiB
HTML
Raw Normal View History

2023-10-06 13:52:09 +08:00
<!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">
2023-10-07 22:29:23 +08:00
import { List, ListItem, useProxy } from './weigets.js'
//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' }] }
//})
//await new Promise(resolve => setTimeout(resolve, 3000))
const store = useProxy({
users: { name: 'users', list: [{ name: 'satori' },{ name: 'sato' }] },
music: { name: 'music', list: [{ name: 'satori' },{ name: 'sato' }] },
image: { name: 'image', list: [{ name: 'satori' },{ name: 'sato' }] },
}, data => {
//console.log('触发了:', data.key, data.value)
console.log('当前数据:', store)
2023-10-06 16:06:17 +08:00
})
2023-10-07 22:29:23 +08:00
//console.log('当前数据:', JSON.stringify(store))
delete store.users.list[1]
//console.log('当前数据:', JSON.stringify(store))
store.users.list.push({ name: 'koishi' })
//store.users.list.push({ name: 'koishi' })
//store.users.list.push({ name: 'koishi' })
//console.log('当前数据:', JSON.stringify(store))
//document.body.appendChild(List({
// children: store.users.list.map(user => ListItem({ textContent: user.name })),
// onclick: () => {
// if (event.target.tagName === 'LI') {
// console.log('点击了:', event.target.textContent)
// }
// //store.users.name = 'koishi'
// store.users.list.push({ name: 'koishi' })
// //store.users.list.pop()
// // 在数据从其他位置被删除时也能删除这里的元素
// }
//}))
2023-10-06 13:52:09 +08:00
</script>
</body>
2023-10-06 16:06:17 +08:00
</html>