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 theme = computed(() => dark.value ? 'dark' : 'light');
|
||||||
const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-white-balance-sunny');
|
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 game = ref<Game | null>(null);
|
||||||
const dealer = ref<boolean | null>(null);
|
const dealer = ref<boolean | null>(null);
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
@ -46,14 +46,15 @@ watchEffect(() => {
|
|||||||
dealer.value = null;
|
dealer.value = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ('id' in data.value) {
|
const m = JSON.parse(data.value) as Game | GameStart;
|
||||||
|
if ('id' in m) {
|
||||||
// Game start.
|
// Game start.
|
||||||
dealer.value = data.value.dealer;
|
dealer.value = m.dealer;
|
||||||
history.replaceState(null, '', `${window.origin}/game/${data.value.id}`);
|
history.replaceState(null, '', `${window.origin}/game/${m.id}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Game state update.
|
// Game state update.
|
||||||
game.value = data.value as Game;
|
game.value = m as Game;
|
||||||
});
|
});
|
||||||
|
|
||||||
const playing = computed(() => game.value != null);
|
const playing = computed(() => game.value != null);
|
||||||
|
Loading…
Reference in New Issue
Block a user