add button to leave the game
This commit is contained in:
parent
90655f75d8
commit
790005aeeb
@ -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<string>(`wss://${window.location.host}/queue`, {
|
const { status, data, send, open, close } = useWebSocket<string>(`wss://${window.location.host}/queue`, {
|
||||||
immediate: false,
|
immediate: false,
|
||||||
});
|
});
|
||||||
const game = ref<Game | null>(null);
|
const game = ref<Game | null>(null);
|
||||||
@ -72,6 +72,12 @@ function clickPlay() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function action(evt: Action) {
|
function action(evt: Action) {
|
||||||
|
if (evt.action === 'quit') {
|
||||||
|
// Just close the connection. The server knows what to do.
|
||||||
|
data.value = null;
|
||||||
|
close(1000, 'I quit.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const s = JSON.stringify({action: evt.action});
|
const s = JSON.stringify({action: evt.action});
|
||||||
console.log('send action', evt, s);
|
console.log('send action', evt, s);
|
||||||
send(s);
|
send(s);
|
||||||
|
@ -35,6 +35,9 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-sheet>
|
</v-sheet>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<v-row class="d-flex justify-center">
|
||||||
|
<v-btn @click="leave">Leave</v-btn>
|
||||||
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -75,4 +78,8 @@ function useItem(evt: number) {
|
|||||||
const action = evt.toString() as "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7";
|
const action = evt.toString() as "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7";
|
||||||
emit('action', { action });
|
emit('action', { action });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function leave() {
|
||||||
|
emit('action', { action: 'quit' });
|
||||||
|
}
|
||||||
</script>
|
</script>
|
Loading…
Reference in New Issue
Block a user