|
|
|
@ -126,10 +126,10 @@ func (c *ClientSocketController) SetToken(socket socketio.Conn, token string) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if playerInfo.BindingUser != "" {
|
|
|
|
|
ctx.User = playerInfo.BindingUser
|
|
|
|
|
userName := playerInfo.BindingUser
|
|
|
|
|
userInfo := c.storeModel.GetUserInfo(playerInfo.BindingUser)
|
|
|
|
|
if playerInfo.BoundUser != "" {
|
|
|
|
|
ctx.User = playerInfo.BoundUser
|
|
|
|
|
userName := playerInfo.BoundUser
|
|
|
|
|
userInfo := c.storeModel.GetUserInfo(playerInfo.BoundUser)
|
|
|
|
|
if userInfo != nil {
|
|
|
|
|
userName = userInfo.DisplayName
|
|
|
|
|
}
|
|
|
|
@ -137,7 +137,7 @@ func (c *ClientSocketController) SetToken(socket socketio.Conn, token string) {
|
|
|
|
|
// 通知客户端
|
|
|
|
|
socket.Emit("user:update", ctx.User, userName)
|
|
|
|
|
// 加入房间
|
|
|
|
|
c.SwitchRoom(socket, "user", playerInfo.BindingUser)
|
|
|
|
|
c.SwitchRoom(socket, "user", playerInfo.BoundUser)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if playerInfo.PairCode != "" { // 删除存储中的code
|
|
|
|
@ -168,6 +168,7 @@ func (c *ClientSocketController) RefreshToken(socket socketio.Conn) {
|
|
|
|
|
|
|
|
|
|
if playerInfo == nil {
|
|
|
|
|
playerInfo = new(store.PlayerInfo)
|
|
|
|
|
playerInfo.Name = utils.GetPlayerNameFromUserAgent(socket.RemoteHeader().Get("User-Agent"))
|
|
|
|
|
} else {
|
|
|
|
|
c.storeModel.RemovePlayerInfo(oldToken)
|
|
|
|
|
}
|
|
|
|
@ -284,7 +285,7 @@ func (c *ClientSocketController) OnBindUser(eventObj ...interface{}) {
|
|
|
|
|
|
|
|
|
|
// 存储信息
|
|
|
|
|
userInfo.BoundPlayer = append(userInfo.BoundPlayer, event.Token)
|
|
|
|
|
playerInfo.BindingUser = event.User
|
|
|
|
|
playerInfo.BoundUser = event.User
|
|
|
|
|
|
|
|
|
|
c.storeModel.SetUserInfo(event.User, userInfo)
|
|
|
|
|
c.storeModel.SetPlayerInfo(event.Token, playerInfo)
|
|
|
|
|