Merge pull request #32 from YousefED/patch-1

Fix room reconnection
This commit is contained in:
Kevin Jahns 2021-11-10 09:57:16 +01:00 committed by GitHub
commit d549c4599f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -358,8 +358,7 @@ export class Room {
encoding.writeVarUint8Array(encoderAwareness, awarenessProtocol.encodeAwarenessUpdate(this.awareness, changedClients)) encoding.writeVarUint8Array(encoderAwareness, awarenessProtocol.encodeAwarenessUpdate(this.awareness, changedClients))
broadcastRoomMessage(this, encoding.toUint8Array(encoderAwareness)) broadcastRoomMessage(this, encoding.toUint8Array(encoderAwareness))
} }
this.doc.on('update', this._docUpdateHandler)
this.awareness.on('update', this._awarenessUpdateHandler)
window.addEventListener('beforeunload', () => { window.addEventListener('beforeunload', () => {
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload') awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload')
rooms.forEach(room => { rooms.forEach(room => {
@ -369,6 +368,9 @@ export class Room {
} }
connect () { connect () {
this.doc.on('update', this._docUpdateHandler)
this.awareness.on('update', this._awarenessUpdateHandler)
// signal through all available signaling connections // signal through all available signaling connections
announceSignalingInfo(this) announceSignalingInfo(this)
const roomName = this.name const roomName = this.name