2022-08-02 20:34:46 +00:00
|
|
|
import { useUserinfoStore } from "@/stores/UserinfoStore"
|
|
|
|
|
2022-08-02 20:20:08 +00:00
|
|
|
export function start(): void {
|
2022-08-02 21:34:30 +00:00
|
|
|
if (this.isActive && !this.shouldStop) {
|
2022-08-01 15:56:51 +00:00
|
|
|
console.warn('attempt to start already running engine!')
|
|
|
|
return
|
|
|
|
}
|
2022-08-02 20:34:46 +00:00
|
|
|
if (useUserinfoStore().isAdmin) {
|
|
|
|
console.debug('user is admin, engine not started')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-08-02 21:34:30 +00:00
|
|
|
this.isActive = true
|
|
|
|
this.shouldStop = false
|
2022-08-05 16:52:34 +00:00
|
|
|
this.isConnected.value = true
|
|
|
|
|
2022-08-02 20:34:46 +00:00
|
|
|
this.fetchUpdate()
|
2022-08-01 15:56:51 +00:00
|
|
|
console.log('start engine')
|
|
|
|
}
|
2022-08-02 20:20:08 +00:00
|
|
|
|
|
|
|
export function stop(): void {
|
2022-08-02 21:34:30 +00:00
|
|
|
if (this.isActive) {
|
|
|
|
this.shouldStop = true
|
2022-08-05 16:52:34 +00:00
|
|
|
this.isConnected.value = true
|
2022-08-02 20:20:08 +00:00
|
|
|
console.log('shut down engine')
|
|
|
|
}
|
|
|
|
}
|