feat: added laravel reverb and websocket, also emote throwing added

This commit is contained in:
2026-08-16 17:10:42 +02:00
parent 50e9fbd0b0
commit 6f47ed0674
30 changed files with 2244 additions and 34 deletions
+33
View File
@@ -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;
}