feat(multiplayer): cap websocket connections per player

This commit is contained in:
Josh Creek
2026-09-01 19:27:45 +01:00
parent 515b06d97c
commit da92be73ef
3 changed files with 48 additions and 7 deletions
+22
View File
@@ -0,0 +1,22 @@
package api
import "testing"
func TestEventHubCapsConnectionsPerPlayerAndReleasesCapacity(t *testing.T) {
hub := newEventHub()
first := hub.subscribe("player-1")
second := hub.subscribe("player-1")
if first == nil || second == nil {
t.Fatal("connection within per-player cap was rejected")
}
if third := hub.subscribe("player-1"); third != nil {
t.Fatal("connection over per-player cap was accepted")
}
hub.unsubscribe(first)
if third := hub.subscribe("player-1"); third == nil {
t.Fatal("released connection capacity was not reusable")
} else {
hub.unsubscribe(third)
}
hub.unsubscribe(second)
}