fix(chat): 优化后台限流与 SSE 日志
This commit is contained in:
@@ -7,6 +7,7 @@ func TestDisconnectUserClosesAllConnections(t *testing.T) {
|
||||
first := hub.Subscribe("user", 7)
|
||||
second := hub.Subscribe("user", 7)
|
||||
hub.Subscribe("user", 8)
|
||||
hub.Subscribe("admin", 9)
|
||||
|
||||
hub.DisconnectUser(7)
|
||||
for name, ch := range map[string]<-chan *ChatEvent{"first": first, "second": second} {
|
||||
@@ -19,7 +20,13 @@ func TestDisconnectUserClosesAllConnections(t *testing.T) {
|
||||
t.Fatalf("%s connection did not close immediately", name)
|
||||
}
|
||||
}
|
||||
if got := hub.OnlineCount(); got != 1 {
|
||||
t.Fatalf("online connection count = %d, want 1", got)
|
||||
if got := hub.OnlineCount(); got != 2 {
|
||||
t.Fatalf("online connection count = %d, want 2", got)
|
||||
}
|
||||
if got := hub.OnlineCountByType("user"); got != 1 {
|
||||
t.Fatalf("online user connection count = %d, want 1", got)
|
||||
}
|
||||
if got := hub.OnlineCountByType("admin"); got != 1 {
|
||||
t.Fatalf("online admin connection count = %d, want 1", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user