crm/frontend/src/socket.js
2023-08-10 19:14:29 +05:30

14 lines
444 B
JavaScript

import { io } from 'socket.io-client'
import { socketio_port } from '../../../../sites/common_site_config.json'
function initSocket() {
let host = window.location.hostname
let port = window.location.port ? `:${socketio_port}` : ''
let protocol = port ? 'http' : 'https'
let url = `${protocol}://${host}${port}/${host}`
let socket = io(url, { withCredentials: true })
return socket
}
let socket = initSocket()
export default socket