Send playerLeave message on close
This commit is contained in:
@@ -81,6 +81,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function leaveLobby() {
|
function leaveLobby() {
|
||||||
|
wsClient.sendMessage({
|
||||||
|
type: 'leaveGame',
|
||||||
|
player: data.user.email
|
||||||
|
})
|
||||||
wsClient.disconnect();
|
wsClient.disconnect();
|
||||||
// In a real app, you'd likely redirect to another page here
|
// In a real app, you'd likely redirect to another page here
|
||||||
}
|
}
|
||||||
@@ -98,7 +102,7 @@
|
|||||||
|
|
||||||
onDestroy(() => {
|
onDestroy(() => {
|
||||||
// Clean up WebSocket connection when component is destroyed
|
// Clean up WebSocket connection when component is destroyed
|
||||||
wsClient.disconnect();
|
leaveLobby()
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user