entanglement server

This commit is contained in:
2023-10-06 14:27:58 +08:00
parent 9340c99755
commit 7d62522f7e
2 changed files with 9 additions and 7 deletions

View File

@@ -18,7 +18,7 @@ export default class Entanglement {
async __create_websocket() {
const host = window.location.host
const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws'
const ws = new WebSocket(`${protocol}://${host}/entanglement`)
const ws = new WebSocket(`${protocol}://${host}/entanglement?name=sato&channel=chat`)
ws.onopen = () => console.log('websocket 连接成功')
ws.onclose = async () => {
console.log('websocket 连接关闭, 3s后尝试重新连接...')
@@ -34,7 +34,7 @@ export default class Entanglement {
const data = JSON.parse(event.data)
//console.log('收到消息', data)
if (data.type === 'list') {
console.debug('收到在线对端列表', data.list)
console.debug('收到在线列表', data.list)
this.users = Promise.all(data.list.map(async user => {
console.debug('发送给', user.name, 'offer')
const pc = this.__create_webrtc()