跨服,获取英雄信息

back_recharge
duhui 2021-11-08 17:23:33 +08:00
parent 00c2cac6ec
commit 9e82d2541a
4 changed files with 43 additions and 15 deletions

View File

@ -5,25 +5,23 @@ import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.store.BuyGoodsNewLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.thrift.idl.*;
import com.ljsd.jieling.thrift.idl.Pokemon;
import com.ljsd.jieling.thrift.idl.PropertyItem;
import com.ljsd.jieling.thrift.idl.PurpleMansionSeal;
import com.ljsd.jieling.thrift.idl.TeamPosHeroInfo;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.RoomProto;
import com.ljsd.jieling.thrift.idl.*;
import com.ljsd.jieling.util.MessageUtil;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ljsd.jieling.thrift.idl.*;
import rpc.thrift.ServiceKey;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.RoomProto;
import util.TimeUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -32,9 +30,21 @@ import java.util.stream.Collectors;
public class CoreService implements RPCRequestIFace.Iface {
private static final Logger LOGGER = LoggerFactory.getLogger(CoreService.class);
/**
*
*/
private CoreService(){
}
public static class Instance {
private final static CoreService INSTANCE = new CoreService();
}
public static CoreService getInstance() {
return CoreService.Instance.INSTANCE;
}
@Override
public Result deliveryRecharge(int uid, String goodsId, String openId, String orderId, long orderTime, int amount) throws InvalidOperException, TException {
public Result deliveryRecharge(int uid, String goodsId, String openId, String orderId, long orderTime, int amount) {
try {
LOGGER.info("deliveryRecharge start",uid );
return BuyGoodsNewLogic.sendGoods(uid, goodsId, openId, orderId, orderTime, amount);
@ -53,7 +63,7 @@ public class CoreService implements RPCRequestIFace.Iface {
}
@Override
public void mathcRoomAdressInfo(int uid, int type, String address) throws TException {
public void mathcRoomAdressInfo(int uid, int type, String address) {
ISession session = OnlineUserManager.getSessionByUid(uid);
if(session!=null){
RoomProto.RoomAddressIndication build = RoomProto.RoomAddressIndication.newBuilder().setAddress(address).setType(type).build();
@ -84,10 +94,14 @@ public class CoreService implements RPCRequestIFace.Iface {
}
@Override
public CrossArenaManager getHeroManagerInfo(int uid) throws TException {
public CrossArenaManager getHeroManagerInfo(int uid) {
long start = TimeUtils.now();
try{
// 编队列表
User user = UserManager.getUserInMem(uid);
User user = UserManager.getUserNotCache(uid);
if (user == null){
return null;
}
Map<Integer,List<TeamPosHeroInfo>> teams = new HashMap<>();
// 需要存储的英雄列表
HashSet<TeamPosHeroInfo> set = new HashSet<>();
@ -192,10 +206,10 @@ public class CoreService implements RPCRequestIFace.Iface {
rpcArenaManager.setPracticeSkillMap(user.getHeroManager().getPracticeSkillMap());
rpcArenaManager.setMaxHistoryForce(user.getPlayerInfoManager().getMaxForce());
LOGGER.error("跨服,获取玩家英雄信息耗时:{}ms",TimeUtils.now()-start);
return rpcArenaManager;
}catch (Exception e){
LOGGER.error("跨服获取玩家英雄信息报错uid:{},error:{}",uid,e.getMessage());
}
return null;
}

View File

@ -354,6 +354,9 @@ public class CrossYuxulundaoChallengeHandler extends BaseHandler<ArenaInfoProto.
public static int[] getFightResultByPersonToPerson(User myUser, int defUserUid, int[] myteamId, int[] defTeamId, ArenaRecord arenaRecord, ArenaInfoProto.CrossYuXuLunDaoChallengeResponse.Builder builder) throws Exception {
int[] result = new int[3];
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(defUserUid);
if (csPlayer == null){
throw new ErrorCodeException(ErrorCode.USE_NOT_EXIT);
}
//其他服玩家rpc 数据调用
CrossArenaManager crossArenaManager = null;
if(GameApplication.serverId != csPlayer.getServerId()){

View File

@ -151,7 +151,7 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
}
int defendForce = 0;
int defendForce;
if (proto.getChallengeUid()>1000) {
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(proto.getChallengeUid());
if (csPlayer == null){

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.player;
import com.ljsd.CoreService;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
import com.ljsd.jieling.config.clazzStaticCfg.TaskStaticConfig;
@ -965,7 +966,18 @@ public class PlayerLogic {
}
return builder.build();
}
/**
* 使
* @param csPlayer
* @return
*/
public CrossArenaManager getCrossArenaManagerData(CSPlayer csPlayer){
// 本服玩家数据
if (csPlayer.getServerId() == GameApplication.serverId){
return CoreService.getInstance().getHeroManagerInfo(csPlayer.getUserId());
}
String rpcString = RedisUtil.getInstence().getObject(RedisKey.LOGIC_SERVER_INFO, String.valueOf(csPlayer.getServerId()), String.class, -1);
String[] split = rpcString.split(":");
if (split.length < 4){
@ -1019,7 +1031,6 @@ public class PlayerLogic {
.setUid(id).setCrossTeamScore(csPlayer.getCrossYuxulundaoNewScore())
.setServerName(serverName);
//如果是本服玩家 直接本服调用数据
CoreSettings coreSettings = ConfigurableApplicationContextManager.getBean(CoreSettings.class);
if(GameApplication.serverId == csPlayer.getServerId()){
User user = UserManager.getUser(id);
return PlayerLogic.getInstance().getCrossYxldMyTeamInfo(user, team);
@ -1239,7 +1250,7 @@ public class PlayerLogic {
throw new ErrorCodeException(ErrorCode.newDefineCode("该玩家没有跨服数据"));
}
//其他服玩家rpc 数据调用
CrossArenaManager crossArenaManager = null;
CrossArenaManager crossArenaManager;
if(GameApplication.serverId == csPlayer.getServerId()){
return viewCrossHeroInfoMyserver(uid,heroId,teamId);
}else{