Signaling server, WS, login, room creation

This commit is contained in:
Thomas
2020-07-27 21:44:36 +02:00
parent 0ef9ba675b
commit c1787cacba
25 changed files with 1114 additions and 123 deletions

View File

@@ -0,0 +1,75 @@
import { DialogProgrammatic as Dialog } from 'buefy'
import router from '@/router/index'
const state = {
signalServerConnected: false,
loginSuccess: false,
error: null,
serverStatus: {}
}
const getters = {
displayError: state => state.error,
displayUserList: state => state.userList,
displayLoginStatus: state => state.loginSuccess,
displayServerStatus: state => state.signalServerConnected
}
const actions = {
signalConnected ({ commit }) {
commit('SIGNAL_SUCCESS')
},
signalError ({ commit }, error) {
commit('SIGNAL_ERROR', error)
},
login ({ commit }, success) {
if (success) commit('LOGIN_SUCCESS')
else commit('LOGIN_ERROR')
},
serverStatus ({ commit }, serverStatus) {
commit('SET_SERVERSTATUS', serverStatus)
},
createRoom ({ commit, dispatch }, code) {
commit('CREATE_ROOM')
dispatch('room/setRoomCode', code, { root: true })
},
error ({ commit }, error) {
commit('ERROR', error)
}
}
const mutations = {
SIGNAL_SUCCESS (state) {
state.signalServerConnected = true
},
SIGNAL_ERROR (state, error) {
state.signalServerConnected = false
state.error = error
},
LOGIN_SUCCESS (state) {
state.loginSuccess = true
},
LOGIN_ERROR (state) {
state.loginSuccess = false
},
SET_SERVERSTATUS (state, serverStatus) {
state.serverStatus = serverStatus
},
CREATE_ROOM (state) {
state.room = true
state.admin = true
router.push({ name: 'Room' })
},
ERROR (state, error) {
state.error = error
Dialog.alert(error)
}
}
export default {
namespaced: true,
state,
getters,
actions,
mutations
}