38 lines
645 B
JavaScript
38 lines
645 B
JavaScript
class Client {
|
|
constructor(client) {
|
|
this.client = client
|
|
this.status = 'await'
|
|
this.name = 'anonymous'
|
|
this.client.emit('id', client.id)
|
|
}
|
|
}
|
|
|
|
class Clients {
|
|
|
|
constructor(io) {
|
|
this.io = io
|
|
this.clients = {}
|
|
}
|
|
|
|
debuglog() {
|
|
console.log('client total:', this.length)
|
|
}
|
|
|
|
add(client) {
|
|
this.clients[client.id] = new Client(client)
|
|
this.debuglog()
|
|
}
|
|
|
|
del(client) {
|
|
delete this.clients[client.id]
|
|
this.debuglog()
|
|
}
|
|
|
|
get length() {
|
|
return Object.entries(this.clients).length
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = Clients
|