Compare commits

..

No commits in common. "6c6995d2dd902fc083a04c2651f9d657df3dfb72" and "622cd80380ec6b2c7e662d148b8a4082e17e1972" have entirely different histories.

2 changed files with 5 additions and 16 deletions

3
.gitignore vendored
View File

@ -37,6 +37,3 @@ config.local.yaml
# 需求文件
todo.txt
# 测试文件
test/

View File

@ -118,22 +118,14 @@ func (c *WSClient) closeConn() {
c.isConnected = false
}
func (c *WSClient) connect() error {
func (c *WSClient) connect() any {
c.mu.Lock()
defer c.mu.Unlock()
conn, _, err := websocket.DefaultDialer.Dial(c.config.ServerURL, nil)
if err != nil {
return err
}
c.mu.Lock()
defer c.mu.Unlock()
select {
case <-c.stopChan:
conn.Close()
return nil
default:
}
c.conn = conn
c.isConnected = true
log.Printf("[网络] 成功连接到服务器: %s", c.config.ServerURL)