mailwolt/resources/js/webserver/websocket.js

24 lines
609 B
JavaScript

import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
import {wsConfig} from "./connector.js";
window.Pusher = Pusher
const host = wsConfig.host || window.location.hostname
const port = Number(wsConfig.port) || 443 // <- post -> port
const scheme = (wsConfig.scheme || 'https').toLowerCase()
const path = wsConfig.path || '/ws'
const tls = scheme === 'https'
const key = wsConfig.key
window.Echo = new Echo({
broadcaster: 'reverb',
key,
wsHost: host,
wsPort: port,
wssPort: port,
forceTLS: tls,
enabledTransports: ['ws', 'wss'],
wsPath: path,
})