'use strict'; import io from 'socket.io-client'; export const INIT_WEB_SOCKET = 'INIT_WEB_SOCKET' export function initWebSocket ({ ioUrl, token }) { if (!ioUrl) { ioUrl = localStorage.getItem('apiRoot') ioUrl = JSON.parse(ioUrl).root } if (!token) { const user = sessionStorage.getItem('vcmpUser') if (user) { token = JSON.parse(user).token } } if (!ioUrl || !token) { return { type: '', } } return dispatch => { const socket = io( ioUrl // 'http://10.8.30.7:4000' , { query: { token: token }, }); dispatch({ type: INIT_WEB_SOCKET, payload: { socket: socket } }) } }