(client *Client)
| 91 | } |
| 92 | |
| 93 | func (h *Hub) Register(client *Client) error { |
| 94 | if client == nil { |
| 95 | return nil |
| 96 | } |
| 97 | h.mux.Lock() |
| 98 | defer h.mux.Unlock() |
| 99 | cli, ok := h.clients[client.ID()] |
| 100 | if ok { |
| 101 | if cli != nil { |
| 102 | return fmt.Errorf("client already registered") |
| 103 | } |
| 104 | } |
| 105 | slog.DebugContext(h.ctx, "registering client", "client_id", client.ID()) |
| 106 | h.clients[client.id] = client |
| 107 | return nil |
| 108 | } |
| 109 | |
| 110 | func (h *Hub) Unregister(client *Client) error { |
| 111 | if client == nil { |
no test coverage detected