ping more often

This commit is contained in:
Branden J Brown 2024-02-02 19:54:22 -06:00
parent 0be7629d9e
commit da516b75f4
2 changed files with 4 additions and 3 deletions

View File

@ -42,7 +42,7 @@ func applyAction(g *game.Match, a action) error {
case "7": case "7":
return g.Apply(a.Player, 7) return g.Apply(a.Player, 7)
case "ping": case "ping":
return nil return errJustAPing
default: default:
return errWeirdAction return errWeirdAction
} }
@ -101,7 +101,7 @@ func gameActor(ctx context.Context, g *game.Match, dealer, chall person, join <-
broadcast(ctx, g, dealer, chall, obs) broadcast(ctx, g, dealer, chall, obs)
g.NextGame() g.NextGame()
broadcast(ctx, g, dealer, chall, obs) broadcast(ctx, g, dealer, chall, obs)
case game.ErrWrongTurn: // do nothing case game.ErrWrongTurn, errJustAPing: // do nothing
case errWeirdAction: case errWeirdAction:
slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action) slog.WarnContext(ctx, "nonsense action", "from", a.Player, "action", a.Action)
default: default:
@ -174,5 +174,6 @@ func gameOver(ctx context.Context, dealer, chall person, obs []observer) {
var ( var (
errWeirdAction = errors.New("unknown action") errWeirdAction = errors.New("unknown action")
errJustAPing = errors.New("just a ping")
errMatchExpired = errors.New("there is a time limit on matches please") errMatchExpired = errors.New("there is a time limit on matches please")
) )

View File

@ -40,7 +40,7 @@ const themeIcon = computed(() => dark.value ? 'mdi-moon-waxing-crescent' : 'mdi-
const { status, data, send, open } = useWebSocket<string>(`wss://${window.location.host}/queue`, { const { status, data, send, open } = useWebSocket<string>(`wss://${window.location.host}/queue`, {
immediate: false, immediate: false,
heartbeat: { heartbeat: {
interval: 5000, interval: 1000,
message: '{"action":"ping"}', message: '{"action":"ping"}',
}, },
}); });