2022-08-02 20:34:46 +00:00
|
|
|
import { useUserinfoStore } from "@/stores/UserinfoStore"
|
2022-09-01 17:17:27 +00:00
|
|
|
import { EngineContext } from '@/composables/useEngine'
|
2022-09-03 19:41:30 +00:00
|
|
|
import useAlert from '@/composables/useAlert'
|
2022-08-02 20:34:46 +00:00
|
|
|
|
2022-09-01 17:17:27 +00:00
|
|
|
export function start(this: EngineContext): 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-09-03 19:41:30 +00:00
|
|
|
useAlert().clearAlert()
|
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-09-03 19:41:30 +00:00
|
|
|
|
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
|
|
|
|
2022-09-01 17:17:27 +00:00
|
|
|
export function stop(this: EngineContext): void {
|
2022-08-02 21:34:30 +00:00
|
|
|
if (this.isActive) {
|
2022-09-03 19:41:30 +00:00
|
|
|
useAlert().clearAlert()
|
2022-08-02 21:34:30 +00:00
|
|
|
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')
|
|
|
|
}
|
|
|
|
}
|