websocket messages are json
This commit is contained in:
parent
8e87ece54f
commit
f7f3e67417
@ -37,7 +37,7 @@ const toggleDark = useToggle(dark);
|
||||
const theme = computed(() => dark.value ? 'dark' : 'light');
|
||||
const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-white-balance-sunny');
|
||||
|
||||
const { status, data, send, open } = useWebSocket<Game | GameStart>(`wss://${window.location.host}/queue`, { immediate: false });
|
||||
const { status, data, send, open } = useWebSocket<string>(`wss://${window.location.host}/queue`, { immediate: false });
|
||||
const game = ref<Game | null>(null);
|
||||
const dealer = ref<boolean | null>(null);
|
||||
watchEffect(() => {
|
||||
@ -46,14 +46,15 @@ watchEffect(() => {
|
||||
dealer.value = null;
|
||||
return;
|
||||
}
|
||||
if ('id' in data.value) {
|
||||
const m = JSON.parse(data.value) as Game | GameStart;
|
||||
if ('id' in m) {
|
||||
// Game start.
|
||||
dealer.value = data.value.dealer;
|
||||
history.replaceState(null, '', `${window.origin}/game/${data.value.id}`);
|
||||
dealer.value = m.dealer;
|
||||
history.replaceState(null, '', `${window.origin}/game/${m.id}`);
|
||||
return;
|
||||
}
|
||||
// Game state update.
|
||||
game.value = data.value as Game;
|
||||
game.value = m as Game;
|
||||
});
|
||||
|
||||
const playing = computed(() => game.value != null);
|
||||
|
Loading…
Reference in New Issue
Block a user