changed socketinit method

This commit is contained in:
srgooglo 2020-10-21 17:53:13 +02:00
parent cc184378af
commit bdc19546fe
2 changed files with 11 additions and 14 deletions

View File

@ -16,7 +16,6 @@ export default {
namespace: 'app',
state: {
env_proccess: process.env,
socket_address: "localhost:7000", //set by default
server_key: keys.server_key,
resolvers: null,
@ -57,6 +56,7 @@ export default {
})
dispatch({ type: 'updateFrames' })
dispatch({ type: 'handleValidate' })
dispatch({ type: 'socket/initializeSocket' })
dispatch({ type: 'queryAuth' })
dispatch({ type: 'query', payload: { dispatcher: dispatch } })
},
@ -127,17 +127,8 @@ export default {
const socket = yield select(state => state.socket)
const state = yield select(state => state)
verbosity([`Starting Auth process`])
yield put({
type: 'socket/initializeSocket',
payload: {
hostname: state.app.socket_address,
reconnectionAttempts: 10
},
then: () => {
return console.log("recived")
}
})

View File

@ -17,6 +17,7 @@ export default {
namespace: 'socket',
state: {
resolvers: null,
socket_address: "localhost:7000", //set by default
ioConn: null,
listeners: {}
},
@ -33,15 +34,20 @@ export default {
},
*initializeSocket({ payload, then }, { select, put }) {
if (!payload) return false
const state = yield select(state => state)
if (payload == null){
payload = {
hostname: state.socket.socket_address,
reconnectionAttempts: 10
}
}
const handleThen = () => {
if (typeof (then) !== "undefined") {
console.log("then callback activated")
return then(true)
}
}
appInterface.notify.proccess("Connecting to server")
yield put({
type: "handleSocket",