mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
modify this.connections
before emiting join event
This commit is contained in:
parent
48024e87d7
commit
4fd3522b01
@ -79,6 +79,9 @@ class Room {
|
|||||||
// join room
|
// join room
|
||||||
socket.join(this.roomName)
|
socket.join(this.roomName)
|
||||||
|
|
||||||
|
// add to connections
|
||||||
|
this.connections.push(socket)
|
||||||
|
|
||||||
// emit to self
|
// emit to self
|
||||||
socket.emit("room:joined", {
|
socket.emit("room:joined", {
|
||||||
room: this.roomName,
|
room: this.roomName,
|
||||||
@ -110,9 +113,6 @@ class Room {
|
|||||||
socket.on(event, handler)
|
socket.on(event, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to connections
|
|
||||||
this.connections.push(socket)
|
|
||||||
|
|
||||||
console.log(`[${socket.id}][@${socket.userData.username}] joined room ${this.roomName}`)
|
console.log(`[${socket.id}][@${socket.userData.username}] joined room ${this.roomName}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +129,8 @@ class Room {
|
|||||||
|
|
||||||
socket.leave(this.roomName)
|
socket.leave(this.roomName)
|
||||||
|
|
||||||
|
this.connections.splice(this.connections.indexOf(socket), 1)
|
||||||
|
|
||||||
socket.emit("room:left", {
|
socket.emit("room:left", {
|
||||||
room: this.roomName,
|
room: this.roomName,
|
||||||
})
|
})
|
||||||
@ -146,8 +148,6 @@ class Room {
|
|||||||
socket.off(event, handler)
|
socket.off(event, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.connections.splice(this.connections.indexOf(socket), 1)
|
|
||||||
|
|
||||||
console.log(`[${socket.id}][@${socket.userData.username}] left room ${this.roomName}`)
|
console.log(`[${socket.id}][@${socket.userData.username}] left room ${this.roomName}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user