mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-12-15 08:19:37 +00:00
Update:Refactor socket connection management into SocketAuthority
This commit is contained in:
parent
42e68edc65
commit
e2af33e136
22 changed files with 386 additions and 341 deletions
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue