Merge remote-tracking branch 'origin/sockets'

# Conflicts:
#	composer.lock
#	public/mix-manifest.json
This commit is contained in:
Čarodej
2022-03-10 07:14:08 +01:00
15 changed files with 1896 additions and 315 deletions

View File

@@ -16,13 +16,15 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
* allows your team to easily build robust real-time web applications.
*/
// import Echo from 'laravel-echo';
import Echo from 'laravel-echo';
// window.Pusher = require('pusher-js');
window.Pusher = require('pusher-js');
// window.Echo = new Echo({
// broadcaster: 'pusher',
// key: process.env.MIX_PUSHER_APP_KEY,
// cluster: process.env.MIX_PUSHER_APP_CLUSTER,
// forceTLS: true
// });
// TODO: set wshost
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'local',
wsHost: '192.168.1.112',
wsPort: 6001,
forceTLS: false
});

View File

@@ -3,6 +3,7 @@ import Vue from 'vue'
import uploadRequest from './modules/uploadRequest'
import fileFunctions from './modules/fileFunctions'
import broadcasting from './modules/broadcasting'
import fileBrowser from './modules/fileBrowser'
import payments from './modules/payments'
import userAuth from './modules/userAuth'
@@ -17,6 +18,7 @@ export default new Vuex.Store({
modules: {
uploadRequest,
fileFunctions,
broadcasting,
fileBrowser,
payments,
userAuth,

View File

@@ -0,0 +1,32 @@
const defaultState = {
isRunningConnection: false,
}
const actions = {
runConnection: ({ commit, getters }) => {
commit('SET_RUNNING_COMMUNICATION')
Echo.private(`test.${getters.user.data.id}`)
.listen('.Domain\\Notifications\\Events\\TestUpdate', (e) => {
console.log(e);
});
},
}
const mutations = {
SET_RUNNING_COMMUNICATION(state) {
state.isRunningConnection = true
},
}
const getters = {
isRunningConnection: (state) => state.isRunningConnection,
}
export default {
state: defaultState,
getters,
actions,
mutations,
}

View File

@@ -10,7 +10,7 @@ const defaultState = {
}
const actions = {
getAppData: ({ commit, getters }) => {
getAppData: ({ commit, getters, dispatch }) => {
return new Promise((resolve, reject) => {
axios
.get(getters.api + '/user' + getters.sorting.URI)
@@ -18,6 +18,10 @@ const actions = {
resolve(response)
commit('RETRIEVE_USER', response.data)
if (! getters.isRunningConnection) {
dispatch('runConnection')
}
})
.catch((error) => {
reject(error)