Skip to content

Commit 2cd5bab

Browse files
committed
refactor(sync_server): change map from bool to struct for clients
1 parent 36075a7 commit 2cd5bab

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/tui/sync_server.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
type SyncServer struct {
1414
listener net.Listener
1515
port int
16-
clients map[net.Conn]bool
16+
clients map[net.Conn]struct{}
1717
clientsMu sync.Mutex
1818
running bool
1919
currentSlide int
@@ -30,7 +30,7 @@ func NewSyncServer() (*SyncServer, error) {
3030
server := &SyncServer{
3131
listener: listener,
3232
port: port,
33-
clients: make(map[net.Conn]bool),
33+
clients: make(map[net.Conn]struct{}),
3434
currentSlide: 0,
3535
}
3636

@@ -58,7 +58,7 @@ func (s *SyncServer) Stop() {
5858
for client := range s.clients {
5959
client.Close()
6060
}
61-
s.clients = make(map[net.Conn]bool)
61+
s.clients = make(map[net.Conn]struct{})
6262
s.clientsMu.Unlock()
6363

6464
slog.Info("Sync server stopped")
@@ -94,7 +94,7 @@ func (s *SyncServer) acceptConnections() error {
9494
}
9595

9696
s.clientsMu.Lock()
97-
s.clients[conn] = true
97+
s.clients[conn] = struct{}{}
9898
s.clientsMu.Unlock()
9999

100100
currentSlide := s.currentSlide

0 commit comments

Comments
 (0)