From be70ee73309a5823f917908d14c10cc60cb8e030 Mon Sep 17 00:00:00 2001 From: filifa Date: Sat, 20 Jul 2024 15:04:19 -0500 Subject: [PATCH] add exceptions for finished games --- cmd/internal/statsapi/websocket.go | 5 +++++ cmd/subscribe.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/internal/statsapi/websocket.go b/cmd/internal/statsapi/websocket.go index 245cb6b..455b3a3 100644 --- a/cmd/internal/statsapi/websocket.go +++ b/cmd/internal/statsapi/websocket.go @@ -26,6 +26,11 @@ type Push struct { UpdateId string } +const ( + GameFinalCode = 4200 + GameUnavailableCode = 4400 +) + type GamedayWebsocket struct { baseURL url.URL *websocket.Conn diff --git a/cmd/subscribe.go b/cmd/subscribe.go index 79f227a..3ed8e86 100644 --- a/cmd/subscribe.go +++ b/cmd/subscribe.go @@ -88,7 +88,7 @@ func subscribe(cmd *cobra.Command, args []string) { var p statsapi.Push err = ws.ReadJSON(&p) - if websocket.IsUnexpectedCloseError(err) { + if websocket.IsUnexpectedCloseError(err, statsapi.GameFinalCode, statsapi.GameUnavailableCode) { log.Println(err) ws.Close()