add match result reporting to game-server

This commit is contained in:
2026-11-10 00:32:54 +03:00
parent dcb76fa570
commit 271daac935
7 changed files with 654 additions and 13 deletions
+11 -1
View File
@@ -21,8 +21,13 @@ type Config struct {
// string into the tokens it issues.
PublicAddr string
// JWTSecret is the HS256 secret shared with the main server; both the
// game token and the user token are verified with it.
// game token and the user token are verified with it. The same secret is
// used to sign match result reports sent back to the main server.
JWTSecret []byte
// MainServerURL is the base URL of the main server's HTTP API
// (e.g. "http://localhost:3000"). Match results are reported to it
// when a match ends.
MainServerURL string
// JoinTimeout is how long the first player waits for the second one
// before the match is cancelled.
JoinTimeout time.Duration
@@ -47,6 +52,11 @@ func Load() (Config, error) {
}
cfg.JWTSecret = []byte(secret)
cfg.MainServerURL = os.Getenv("MAIN_SERVER_URL")
if cfg.MainServerURL == "" {
return cfg, fmt.Errorf("MAIN_SERVER_URL is required (base URL of the main server, e.g. http://localhost:3000)")
}
joinTimeout, err := parseDuration(getenv("JOIN_TIMEOUT", "2m"))
if err != nil {
return cfg, fmt.Errorf("invalid JOIN_TIMEOUT: %w", err)