mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-11-30 20:24:05 +01:00
Update:Refactor socket connection management into SocketAuthority
This commit is contained in:
1 parent
42e68edc65
commit
e2af33e136
22 files changed
+386
-341
No files matched your search
@@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user