add sleep for 2 seconds before /join on reconnect, may be moving too fast and it gets lost
This commit is contained in:
@@ -226,9 +226,17 @@ func (c *Client) handleDisconnect() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Println("🟢 Reconnected successfully")
|
log.Println("🟢 Reconnected successfully")
|
||||||
|
|
||||||
|
// 🚦 Allow websocket handshake to stabilize
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
|
// 🔁 Re-join chat room and verify connection
|
||||||
c.joinRoom()
|
c.joinRoom()
|
||||||
|
c.Send("/ping")
|
||||||
|
log.Printf("🔁 Rejoined Sneedchat room %d after reconnect", c.roomID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *Client) Disconnect() {
|
func (c *Client) Disconnect() {
|
||||||
close(c.stopCh)
|
close(c.stopCh)
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
|
|||||||
Reference in New Issue
Block a user