opt: close the old connection for mj and sd clients

This commit is contained in:
RockYang
2024-04-15 09:34:20 +08:00
parent 9a1368ef17
commit 8a9f386d8f
5 changed files with 82 additions and 28 deletions

View File

@@ -61,6 +61,10 @@ func (h *SdJobHandler) Client(c *gin.Context) {
}
client := types.NewWsClient(ws)
// close the existed connections
if cli := h.pool.Clients.Get(uint(userId)); cli != nil {
cli.Close()
}
h.pool.Clients.Put(uint(userId), client)
logger.Infof("New websocket connected, IP: %s", c.RemoteIP())
}