合服测试3
parent
e8c17d38dd
commit
0166becd77
|
@ -1,6 +1,8 @@
|
||||||
package com.ljsd.jieling.core;
|
package com.ljsd.jieling.core;
|
||||||
|
|
||||||
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
|
import com.ljsd.jieling.db.mongo.core.CHefuInfo;
|
||||||
import com.ljsd.jieling.db.mongo.core.ServerAreaInfoManager;
|
import com.ljsd.jieling.db.mongo.core.ServerAreaInfoManager;
|
||||||
import com.ljsd.jieling.logic.dao.SCdkInfo;
|
import com.ljsd.jieling.logic.dao.SCdkInfo;
|
||||||
import com.ljsd.jieling.logic.dao.root.UserInfo;
|
import com.ljsd.jieling.logic.dao.root.UserInfo;
|
||||||
|
@ -30,13 +32,22 @@ public class CoreLogic {
|
||||||
public final static CoreLogic instance = new CoreLogic();
|
public final static CoreLogic instance = new CoreLogic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServerAreaInfoManager findServerArenaInfoManager() throws Exception{
|
||||||
|
MongoTemplate coreMongoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||||
public ServerAreaInfoManager findServerArenaInfoManager() throws Exception{
|
|
||||||
MongoTemplate coreMongoTemplate =MongoUtil.getCoreMongoTemplate();
|
|
||||||
return coreMongoTemplate.findById(1,ServerAreaInfoManager.class);
|
return coreMongoTemplate.findById(1,ServerAreaInfoManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CHefuInfo findHefuInfo() {
|
||||||
|
MongoTemplate coreMongoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||||
|
Query query = new Query(Criteria.where("serverId").is(GameApplication.serverId));
|
||||||
|
return coreMongoTemplate.findOne(query, CHefuInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHefu(int serverId) {
|
||||||
|
CHefuInfo hefuInfo = findHefuInfo();
|
||||||
|
return hefuInfo.getSlaveServerIds().contains(serverId);
|
||||||
|
}
|
||||||
|
|
||||||
public int findServerIdFromMongo(int uid) {
|
public int findServerIdFromMongo(int uid) {
|
||||||
MongoTemplate coreMongoTemplate = MongoUtil.getCoreMongoTemplate();
|
MongoTemplate coreMongoTemplate = MongoUtil.getCoreMongoTemplate();
|
||||||
Query query = new Query(Criteria.where("_id").is(uid));
|
Query query = new Query(Criteria.where("_id").is(uid));
|
||||||
|
|
|
@ -416,28 +416,25 @@ public class AreaManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getServerIdByUid(int uid, int defaultServerId) {
|
public int getServerIdByUid(int uid, int defaultServerId) {
|
||||||
// if (defaultServerId == GameApplication.serverId){
|
if (defaultServerId == GameApplication.serverId){
|
||||||
// return defaultServerId;
|
return defaultServerId;
|
||||||
// }
|
|
||||||
|
|
||||||
if (serverIds.contains(uid)) {
|
|
||||||
return uid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer serverIdByUid = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, Integer.toString(uid), Integer.class, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
Integer serverIdByUid = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, Integer.toString(uid), Integer.class, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
||||||
if (serverIdByUid != null) {
|
if (serverIdByUid != null && !CoreLogic.getInstance().isHefu(serverIdByUid)) {
|
||||||
return serverIdByUid;
|
return serverIdByUid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int serverIdFromMongo = CoreLogic.getInstance().findServerIdFromMongo(uid);
|
int serverIdFromMongo = CoreLogic.getInstance().findServerIdFromMongo(uid);
|
||||||
if (serverIdFromMongo > 0) {
|
if (serverIdFromMongo != 0 && !CoreLogic.getInstance().isHefu(serverIdFromMongo)){
|
||||||
String key = RedisKey.CUser_ServerId_Key + RedisKey.Delimiter_colon + uid;
|
return serverIdFromMongo;
|
||||||
RedisUtil.getInstence().setObject(key, Integer.toString(serverIdFromMongo), GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
|
||||||
}
|
}
|
||||||
return serverIdFromMongo;
|
|
||||||
|
return GameApplication.serverId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void putCUserServer(int uid, int serverId){
|
public void putCUserServer(int uid, int serverId){
|
||||||
// String key = RedisKey.CUser_ServerId_Key + RedisKey.Delimiter_colon + uid;
|
String key = RedisKey.CUser_ServerId_Key + RedisKey.Delimiter_colon + uid;
|
||||||
// RedisUtil.getInstence().setObject(key, serverId, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
RedisUtil.getInstence().setObject(key, serverId, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
package com.ljsd.jieling.db.mongo.core;
|
||||||
|
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
|
import org.springframework.data.mongodb.core.mapping.Field;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author hj
|
||||||
|
* @Date 2023/5/17 17:22:10
|
||||||
|
* @Description:
|
||||||
|
* @Version 1.0
|
||||||
|
*/
|
||||||
|
@Document(collection = "c_hefu_info")
|
||||||
|
public class CHefuInfo {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private int id;
|
||||||
|
|
||||||
|
@Field(value = "masterServerId")
|
||||||
|
private int masterServerId;
|
||||||
|
|
||||||
|
@Field(value = "slaveServerIds")
|
||||||
|
private List<Integer> slaveServerIds;
|
||||||
|
|
||||||
|
public int getMasterServerId() {
|
||||||
|
return masterServerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMasterServerId(int masterServerId) {
|
||||||
|
this.masterServerId = masterServerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getSlaveServerIds() {
|
||||||
|
return slaveServerIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSlaveServerIds(List<Integer> slaveServerIds) {
|
||||||
|
this.slaveServerIds = slaveServerIds;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1587,9 +1587,11 @@ public class RedisUtil {
|
||||||
return type + RedisKey.Delimiter_colon + key;
|
return type + RedisKey.Delimiter_colon + key;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, key, Integer.class, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
if (!RedisKey.newAreaCacChe.contains(type) && !RedisKey.rankCacChe.contains(type) && key.length() == 8) {
|
||||||
if (serverId != null){
|
Integer serverId = RedisUtil.getInstence().getObject(RedisKey.CUser_ServerId_Key, key, Integer.class, GlobalsDef.REDIS_OVER_TIME_DAY * 10);
|
||||||
return serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
if (serverId != null) {
|
||||||
|
return serverId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AreaManager.areaId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
return AreaManager.areaId + RedisKey.Delimiter_colon + type + RedisKey.Delimiter_colon + key;
|
||||||
|
|
|
@ -84,9 +84,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
||||||
int token = netData.getToken();
|
int token = netData.getToken();
|
||||||
int msgId = netData.getMsgId();
|
int msgId = netData.getMsgId();
|
||||||
int msgIndex = netData.getIndex();
|
int msgIndex = netData.getIndex();
|
||||||
|
AreaManager.getInstance().putCUserServer(userId,GameApplication.serverId);
|
||||||
// AreaManager.getInstance().putCUserServer(userId, GameApplication.serverId);
|
|
||||||
|
|
||||||
PlayerInfoProto.GetPlayerInfoRequest getPlayerInfoRequest = PlayerInfoProto.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
PlayerInfoProto.GetPlayerInfoRequest getPlayerInfoRequest = PlayerInfoProto.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
|
||||||
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
|
||||||
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
|
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
|
||||||
|
|
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
||||||
import com.ljsd.GameApplication;
|
import com.ljsd.GameApplication;
|
||||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||||
import com.ljsd.jieling.config.clazzStaticCfg.TaskStaticConfig;
|
import com.ljsd.jieling.config.clazzStaticCfg.TaskStaticConfig;
|
||||||
|
import com.ljsd.jieling.core.CoreLogic;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||||
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
|
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
|
||||||
|
@ -1777,16 +1778,6 @@ public class PlayerLogic {
|
||||||
if (rpcString == null) {
|
if (rpcString == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// 合服
|
|
||||||
String localRpc = RedisUtil.getInstence().getObject(RedisKey.LOGIC_SERVER_INFO, String.valueOf(GameApplication.serverId), String.class, -1);
|
|
||||||
if (localRpc != null && localRpc.equals(rpcString)) {
|
|
||||||
try {
|
|
||||||
return UserManager.getUser(uid, true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.info("getUserByRpc Exception uid={} e={}", uid, e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] split = rpcString.split(":");
|
String[] split = rpcString.split(":");
|
||||||
if (split.length < 4) {
|
if (split.length < 4) {
|
||||||
|
|
Loading…
Reference in New Issue