fix: sync close ws conn when kick old user avoid wrong trigger order about online status.

This commit is contained in:
Gordon 2023-11-08 17:42:53 +08:00
parent 82a8f3351f
commit a1aba2a628
2 changed files with 4 additions and 7 deletions

View File

@ -297,7 +297,9 @@ func (c *Client) KickOnlineMessage() error {
resp := Resp{
ReqIdentifier: WSKickOnlineMsg,
}
return c.writeBinaryMsg(resp)
err := c.writeBinaryMsg(resp)
c.close()
return err
}
func (c *Client) writeBinaryMsg(resp Resp) error {

View File

@ -225,12 +225,7 @@ func (ws *WsServer) registerClient(client *Client) {
ws.onlineUserNum.Add(1)
ws.onlineUserConnNum.Add(1)
} else {
i := &kickHandler{
clientOK: clientOK,
oldClients: oldClients,
newClient: client,
}
ws.kickHandlerChan <- i
ws.multiTerminalLoginChecker(clientOK, oldClients, client)
log.ZDebug(client.ctx, "user exist", "userID", client.UserID, "platformID", client.PlatformID)
if clientOK {
ws.clients.Set(client.UserID, client)