From ec2480f48cb7d36728386a3fb8f5aa41b19bbd01 Mon Sep 17 00:00:00 2001 From: Branden J Brown Date: Fri, 2 Feb 2024 21:29:13 -0600 Subject: [PATCH] don't heartbeat at all --- server.go | 8 +++----- site/src/App.vue | 11 ++++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/server.go b/server.go index fc56fbe..1294225 100644 --- a/server.go +++ b/server.go @@ -200,11 +200,9 @@ func (s *Server) joinAndServe(p person) { ch := make(chan struct{}) go func() { defer close(ch) - for { - _, _, err := p.conn.Read(context.Background()) - if err != nil || ctx.Err() != nil { - return - } + _, _, err := p.conn.Read(ctx) + if err != nil { + slog.ErrorContext(ctx, "player dropped on hello", "player", p.id, "err", err.Error()) } }() id, chall, deal := s.l.Queue(ctx, p.id) diff --git a/site/src/App.vue b/site/src/App.vue index b38ab7b..cf71df3 100644 --- a/site/src/App.vue +++ b/site/src/App.vue @@ -39,15 +39,11 @@ const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi- const { status, data, send, open } = useWebSocket(`wss://${window.location.host}/queue`, { immediate: false, - heartbeat: { - interval: 1000, - message: '{"action":"ping"}', - }, - onDisconnected: (ws, evt) => { - console.warn('lost connection', {evt}); + onDisconnected: (_ws, evt) => { + console.warn('lost connection', { evt }); game.value = null; dealer.value = null; - } + }, }); const game = ref(null); const dealer = ref(null); @@ -77,6 +73,7 @@ const loading = computed(() => status.value === 'CONNECTING' || status.value === function clickPlay() { open(); + send('hi'); } function action(evt: Action) {