Update:Refactor socket connection management into SocketAuthority

This commit is contained in:
advplyr 2022-11-24 15:53:58 -06:00
parent 42e68edc65
commit e2af33e136
22 changed files with 386 additions and 341 deletions

View file

@ -1,19 +1,19 @@
class TaskManager {
constructor(emitter) {
this.emitter = emitter
const SocketAuthority = require('../SocketAuthority')
class TaskManager {
constructor() {
this.tasks = []
}
addTask(task) {
this.tasks.push(task)
this.emitter('task_started', task.toJSON())
SocketAuthority.emitter('task_started', task.toJSON())
}
taskFinished(task) {
if (this.tasks.some(t => t.id === task.id)) {
this.tasks = this.tasks.filter(t => t.id !== task.id)
this.emitter('task_finished', task.toJSON())
SocketAuthority.emitter('task_finished', task.toJSON())
}
}
}