Skip to content

Commit

Permalink
fix: sync close ws conn when kick old user avoid wrong trigger order …
Browse files Browse the repository at this point in the history
…about online status. (#1368)
  • Loading branch information
FGadvancer authored Nov 8, 2023
1 parent 3ba861f commit b562da5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 3 additions & 1 deletion internal/msggateway/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 1 addition & 6 deletions internal/msggateway/n_ws_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b562da5

Please sign in to comment.