mirror of
https://github.com/ericasch6/scrum-poker-internal.git
synced 2026-10-13 22:32:08 +00:00
feat: added laravel reverb and websocket, also emote throwing added
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import Echo from 'laravel-echo';
|
||||
import Pusher from 'pusher-js';
|
||||
|
||||
let echoClient: Echo<'reverb'> | null = null;
|
||||
|
||||
function environmentString(key: string): string | undefined {
|
||||
const value = import.meta.env[key];
|
||||
|
||||
return typeof value === 'string' && value !== '' ? value : undefined;
|
||||
}
|
||||
|
||||
export function getEcho(): Echo<'reverb'> {
|
||||
if (echoClient !== null) {
|
||||
return echoClient;
|
||||
}
|
||||
|
||||
const scheme = environmentString('VITE_REVERB_SCHEME') ?? 'http';
|
||||
const forceTLS = scheme === 'https';
|
||||
|
||||
echoClient = new Echo<'reverb'>({
|
||||
broadcaster: 'reverb',
|
||||
Pusher,
|
||||
key: environmentString('VITE_REVERB_APP_KEY') ?? 'local-key',
|
||||
wsHost:
|
||||
environmentString('VITE_REVERB_HOST') ?? window.location.hostname,
|
||||
wsPort: Number(environmentString('VITE_REVERB_PORT') ?? 8080),
|
||||
wssPort: Number(environmentString('VITE_REVERB_PORT') ?? 443),
|
||||
forceTLS,
|
||||
enabledTransports: ['ws', 'wss'],
|
||||
});
|
||||
|
||||
return echoClient;
|
||||
}
|
||||
Reference in New Issue
Block a user