stop engine when leaving /play
This commit is contained in:
parent
0014a81ce3
commit
ab5416a547
@ -10,6 +10,9 @@ export default {
|
||||
async mounted() {
|
||||
await this.$engine.start()
|
||||
},
|
||||
async beforeDestroy() {
|
||||
await this.$engine.stop()
|
||||
},
|
||||
computed: {
|
||||
userJson() {
|
||||
return JSON.stringify(this.$store.state.engine.user, null, 2)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import buildUrl from 'build-url'
|
||||
|
||||
export default (context, inject) => {
|
||||
const { store, $axios, $config } = context
|
||||
const { store, $axios, $config, redirect } = context
|
||||
|
||||
const engine = {
|
||||
lastFetched: [0, 0, 0, 0, 0],
|
||||
@ -11,7 +11,7 @@ export default (context, inject) => {
|
||||
async start() {
|
||||
if (!store.state.engine.user) {
|
||||
if (!await this.fetchUserInfo()) {
|
||||
window.location.href = "/"
|
||||
redirect('/')
|
||||
}
|
||||
}
|
||||
if (this.isActive) {
|
||||
@ -70,8 +70,8 @@ export default (context, inject) => {
|
||||
|
||||
async fetchUserInfo() {
|
||||
try {
|
||||
const user = await $axios.$get('/api/userinfo')
|
||||
store.commit('engine/setUser', user)
|
||||
const response = await $axios.get('/api/userinfo')
|
||||
store.commit('engine/setUser', response.data)
|
||||
} catch(e) {
|
||||
store.commit('engine/setUser', undefined)
|
||||
return false
|
||||
|
@ -1,7 +1,6 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -22,7 +21,6 @@ func (app *Application) expireInactivePlayersThread() {
|
||||
}
|
||||
|
||||
gm.EventPlayerLeaves(usr)
|
||||
fmt.Printf("expired %s\n", usrId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user