This commit is contained in:
2024-09-30 23:28:02 +07:00
parent e9e93e2162
commit d53369f529
14 changed files with 157 additions and 20 deletions

View File

@ -39,6 +39,7 @@ func NewTCPServer(address string, port string, log *log.Logger) *TCPServer {
MsgChan: make(chan string),
CmdChan: make(chan string),
Log: log,
Mutex: new(sync.Mutex),
}
}
@ -87,7 +88,6 @@ func (s *TCPServer) handleConnection() {
s.Mutex.Lock()
delete(s.Clients, s.Conn)
s.Mutex.Unlock()
s.Log.Infof("client %s disconnected", s.Conn.RemoteAddr().String())
return
}
@ -98,6 +98,7 @@ func (s *TCPServer) handleConnection() {
s.Mutex.Lock()
delete(s.Clients, s.Conn)
s.Mutex.Unlock()
s.Conn.Close()
s.Log.Infof("client %s disconnected", s.Conn.RemoteAddr().String())
}