// 发送封号信息 // clientObj:客户端对象 func SendForbidMsg(clientObj *client.Client) { responseObj := responseDataObject.NewSocketResponseObject(commandType.Login) responseObj.SetResultStatus(responseDataObject.PlayerIsForbidden) // 先发送消息,然后再断开连接 responseResult(clientObj, responseObj) clientObj.LogoutAndQuit() }
// 发送在另一台设备登陆的信息 // clientObj:客户端对象 func SendLoginAnotherDeviceMsg(clientObj *client.Client) { responseObj := responseDataObject.NewSocketResponseObject(commandType.Login) responseObj.SetResultStatus(responseDataObject.LoginOnAnotherDevice) // 先发送消息,然后再断开连接 responseResult(clientObj, responseObj) clientObj.LogoutAndQuit() }
// 根据客户端对象来断开连接 // 注销客户端连接 // 从缓存中移除玩家对象 // clientObj:客户端对象 // clinetDisconnectType:客户端断开连接的类型;如果是来自于rpc则意味着之前客户端已经关闭连接,现在需要将客户端对象从缓存中移除了;否则是客户端过期,需要关闭 func DisconnectByClient(clientObj *client.Client, clinetDisconnectType disconnectType.ClientDisconnectType) { // 将玩家从缓存中移除 if clientObj.PlayerId() != "" { if playerObj, exists, err := GetPlayer(clientObj.PlayerId(), false); err == nil && exists { UnRegisterPlayer(playerObj) } } // 注销客户端连接,并从缓存中移除 switch clinetDisconnectType { case disconnectType.FromExpire: clientObj.LogoutAndQuit() case disconnectType.FromRpc: clientBLL.UnRegisterClient(clientObj) } }