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

pull/1374/head
Gordon 1 year ago committed by GitHub
parent 3ba861fd90
commit b562da5c37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

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

Loading…
Cancel
Save