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
+27
View File
@@ -0,0 +1,27 @@
import { onScopeDispose, watch } from 'vue';
import { getEcho } from '@/lib/echo';
import type { PaperBallThrownPayload } from '@/types/emote';
const PAPER_BALL_EVENT = '.room.emote.thrown';
export function useRoomEmotes(
roomId: () => string,
onPaperBallThrown: (payload: PaperBallThrownPayload) => void,
): void {
const stopWatchingRoom = watch(
roomId,
(nextRoomId, _previousRoomId, onCleanup) => {
const channel = getEcho().channel(`rooms.${nextRoomId}`);
channel.listen(PAPER_BALL_EVENT, onPaperBallThrown);
onCleanup(() => {
channel.stopListening(PAPER_BALL_EVENT, onPaperBallThrown);
});
},
{ immediate: true },
);
onScopeDispose(stopWatchingRoom);
}