This commit is contained in:
boufni95 2025-01-27 21:24:12 +00:00
parent 0553d9cd6a
commit d3c728d6be

View file

@ -31,7 +31,6 @@ export default class webRTC {
return this.onCandidate(u, message.candidate) return this.onCandidate(u, message.candidate)
} }
return {} return {}
} }
private onCandidate = async (u: UserInfo, candidate: string): Promise<Types.WebRtcAnswer> => { private onCandidate = async (u: UserInfo, candidate: string): Promise<Types.WebRtcAnswer> => {
const key = this.getConnectionsKey(u) const key = this.getConnectionsKey(u)
@ -49,6 +48,7 @@ export default class webRTC {
} }
private connect = async (u: UserInfo, offer: string): Promise<Types.WebRtcAnswer> => { private connect = async (u: UserInfo, offer: string): Promise<Types.WebRtcAnswer> => {
const key = this.getConnectionsKey(u) const key = this.getConnectionsKey(u)
console.log("connect", key)
if (this.connections[key]) { if (this.connections[key]) {
throw new Error('Connection already exists') throw new Error('Connection already exists')
} }
@ -80,6 +80,7 @@ export default class webRTC {
const answer = await conn.createAnswer() const answer = await conn.createAnswer()
await conn.setLocalDescription(answer) await conn.setLocalDescription(answer)
this.connections[key] = conn this.connections[key] = conn
console.log("answer", answer)
return { answer: JSON.stringify(answer) } return { answer: JSON.stringify(answer) }
} }