mirror of
https://github.com/twofas/2fas-server.git
synced 2024-12-04 16:20:13 +01:00
review comments fixes
This commit is contained in:
parent
01a306ea5b
commit
5a23537181
@ -5,16 +5,16 @@ import (
|
||||
)
|
||||
|
||||
type Hub struct {
|
||||
id string
|
||||
onHubIsHasNoClients func(id string)
|
||||
clients *sync.Map
|
||||
id string
|
||||
onHubHasNoClients func(id string)
|
||||
clients *sync.Map
|
||||
}
|
||||
|
||||
func NewHub(id string, notifyOnEmpty func(id string)) *Hub {
|
||||
h := &Hub{
|
||||
id: id,
|
||||
clients: &sync.Map{},
|
||||
onHubIsHasNoClients: notifyOnEmpty,
|
||||
id: id,
|
||||
clients: &sync.Map{},
|
||||
onHubHasNoClients: notifyOnEmpty,
|
||||
}
|
||||
return h
|
||||
}
|
||||
@ -30,7 +30,7 @@ func (h *Hub) unregisterClient(c *Client) {
|
||||
}
|
||||
close(c.send)
|
||||
if h.isEmpty() {
|
||||
h.onHubIsHasNoClients(h.id)
|
||||
h.onHubHasNoClients(h.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func TestRemovingEmptyHub(t *testing.T) {
|
||||
_, h2 := hp.registerClient(channelID, &websocket.Conn{})
|
||||
|
||||
if !h1.isEmpty() {
|
||||
t.Fatalf("Hub does not report it is empty, even though uit should")
|
||||
t.Fatalf("Hub does not report it is empty, even though it should")
|
||||
}
|
||||
if h1 == h2 {
|
||||
t.Fatal("Old hub wasn't deleted")
|
||||
@ -56,7 +56,7 @@ func TestCreateRemoveConcurrently(t *testing.T) {
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(channelsNo * clientsPerChannel)
|
||||
for i := 0; i < channelsNo; i++ {
|
||||
var channelID = fmt.Sprintf("channel-%d", i)
|
||||
channelID := fmt.Sprintf("channel-%d", i)
|
||||
go func() {
|
||||
for j := 0; j < clientsPerChannel; j++ {
|
||||
c, h := hp.registerClient(channelID, &websocket.Conn{})
|
||||
|
Loading…
Reference in New Issue
Block a user