ping more often
This commit is contained in:
parent
0be7629d9e
commit
da516b75f4
5
game.go
5
game.go
@ -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")
|
||||||
)
|
)
|
||||||
|
@ -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"}',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user