cheetah-framework
Version:
Cheetah Framework JS used in all our applications
38 lines (31 loc) • 960 B
JavaScript
import Echo from 'laravel-echo'
import Pusher from 'pusher-js'
import config from '@cheetah/config'
window.echoActive = false
if (config.disableEcho !== true) {
let echoOptions = null
const pusherConfig = window.Cheetah.pusher
const wsHost = pusherConfig?.host
const cluster = pusherConfig?.cluster || ''
const key = pusherConfig?.key
if (key && (wsHost || cluster)) {
echoOptions = {
broadcaster: 'pusher',
key,
cluster,
forceTLS: pusherConfig.useTLS == null ? true : pusherConfig.useTLS
}
if (wsHost) {
echoOptions.wsHost = wsHost
echoOptions.enabledTransports = ['ws', 'wss']
}
window.Pusher = Pusher
window.Pusher.logToConsole = pusherConfig.debug == null ? false : pusherConfig.debug
} else {
console.error('Missing pusher config for Echo')
}
if (echoOptions) {
window.Echo = new Echo({ ...echoOptions, ...config.echoOptions })
window.echoActive = true
}
}