back_recharge
zhangshanxue 2019-09-09 16:35:15 +08:00
commit 2aa64192a4
21 changed files with 269 additions and 51 deletions

View File

@ -181,7 +181,6 @@ public abstract class Creature extends SceneActor{
if(update){
path.clear();
getScene().processEventUpdate(EventType.SCENEACTORE_UPDATE,this.getId());
System.out.println("can not move next" + getId() + " hit the " + sceneActor.getId());
}
return false;

View File

@ -53,6 +53,11 @@ public class Scene implements Runnable{
private Map<Integer, AnalysisData> analysisDataMap = new HashMap<>();
public AnalysisData getAnalysisData(int id){
return analysisDataMap.get(id);
}
public void randomMineralOfUserDeath(Creature creature,int totalMineal){
if(totalMineal <=0){
return;
@ -125,18 +130,14 @@ public class Scene implements Runnable{
Integer value = next.getValue();
if(tick>value){
Integer monsterIndex = next.getKey();
System.out.println("the actor siz=" + sceneActorMap.size());
SceneManager.createMonster(this,monsterIndex);
processEventUpdate(EventType.SCENEACTORE_UPDATE,monsterIndex);
iterator.remove();
System.out.println("the actor after siz=" + sceneActorMap.size());
System.out.println("the monsterid={}" + monsterIndex + "recovery");
}
}
}
public void whenMonsterDead(int deadId){
System.out.println("the monster deadID="+deadId);
SBloodyBattleSetting sBloodyBattleSetting = SBloodyBattleSetting.sBloodyBattleSetting;
int[] monsterItem = sBloodyBattleSetting.getMonsterIndexMap().get(deadId);
monsterRecoryMap.put(deadId,monsterItem[1]*20 + tick);
@ -159,12 +160,11 @@ public class Scene implements Runnable{
if(msgUpdate || !cacheMsg.isEmpty()){
for(Integer removeId : builder.getRemoveActorIdList()){
sceneActorMap.remove(removeId);
System.out.println("remove the id=------------" + removeId);
}
for(SceneActor sceneActor : sceneActorMap.values()){
if(sceneActor.getType() != ActorType.Npc){
if(willUpdateActors.contains(sceneActor.getId())){
builder.addSceneActor(BeanToProto.getSceneActor(sceneActor));
builder.addSceneActor(BeanToProto.getSceneActor(this,sceneActor));
}
}
}
@ -200,7 +200,6 @@ public class Scene implements Runnable{
*/
public void processEventUpdate(EventType eventType,Object parm){
msgUpdate = true;
System.out.println("the eventType = "+ eventType);
switch (eventType){
case SCENEACTORE_UPDATE:
willUpdateActors.add((int)parm);
@ -215,7 +214,6 @@ public class Scene implements Runnable{
case SCENEACTORE_REMOVE:
int deadId = (int) parm;
builder.addRemoveActorId(deadId);
System.out.println("remove the scene id is " + deadId);
break;
case POSMINERAL_REMOVE:
builder.addRemovePosMineralId( (int) parm);
@ -296,7 +294,6 @@ public class Scene implements Runnable{
needAdd = flushNums;
}
SceneManager.createMinear(this,size,needAdd);
System.out.println("创建矿....");
}
}
@ -307,7 +304,7 @@ public class Scene implements Runnable{
//退出操作
public void gameEnd() {
System.out.println("game ending....");
LOGGER.info("the roomId={} is gameEnding" ,roomId);
isEnd = true;
//结算操作
List<SortDataBean> sortDataBeans = new ArrayList<>();
@ -365,7 +362,6 @@ public class Scene implements Runnable{
executorService.submit(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
System.out.println("exce com.ljsd.battle...............................");
SceneActor attackActor = battleRequest.getAttackActor();
SceneActor defActor = battleRequest.getDefActor();
SceneActor temp = null;
@ -395,8 +391,6 @@ public class Scene implements Runnable{
effectBuffer.clearvalues();
effectBuffer.addEffectValue(checkResult[0]);
effectBuffer.setEndTime(effectBuffer.getStartTime() + displayTime *1000);
System.out.println(effectBuffer);
System.out.println(attackActor.getId());
}
}
Map<Integer, EffectBuffer> defBufferMap = defActor.getBufferMap();
@ -405,8 +399,6 @@ public class Scene implements Runnable{
effectBuffer.clearvalues();
effectBuffer.addEffectValue(checkResult[0]==1?0:1);
effectBuffer.setEndTime(effectBuffer.getStartTime() + displayTime *1000);
System.out.println(effectBuffer);
}
}
return 1;

View File

@ -165,8 +165,9 @@ public abstract class SceneActor{
// 定位到出生点位置
this.setPos(SceneManager.selectForPlayerRebirth(scene));
scene.processEventUpdate(EventType.SCENEACTORE_UPDATE,id);
MessageBoxUtils.onGameEvent(AnalysisEventType.BATTLE,scene,new AnalysisSourceData(value.getTarget(),value.getCaster(),effectValue));
if(scene.getSceneActorMap().containsKey(value.getCaster()) &&scene.getSceneActorMap().get(value.getCaster()).getType() == ActorType.Player){
MessageBoxUtils.onGameEvent(AnalysisEventType.BATTLE,scene,new AnalysisSourceData(value.getTarget(),value.getCaster(),effectValue));
}
}else{
Creature creature = (Creature) scene.getSceneActorMap().get(value.getCaster());
if(creature.getType() == ActorType.Monster){
@ -184,7 +185,7 @@ public abstract class SceneActor{
}
}
}
if(this.getType() == ActorType.Player){
if(this.getType() == ActorType.Player && creature.getType() == ActorType.Player){
MessageBoxUtils.onGameEvent(AnalysisEventType.BATTLE,scene,new AnalysisSourceData(value.getTarget(),value.getCaster(),effectValue));
}
stateType = StateType.MOVEABLE;

View File

@ -1,6 +1,7 @@
package com.ljsd.battle.room;
import com.ljsd.battle.manager.BattleManager;
import com.ljsd.battle.statics.AnalysisData;
import com.ljsd.battle.vo.UserBloodySnpInfo;
import com.ljsd.battle.actor.*;
@ -14,7 +15,7 @@ import java.util.Map;
public class BeanToProto {
public static CommonProto.SceneActor getSceneActor(SceneActor sceneActor){
public static CommonProto.SceneActor getSceneActor(Scene scene,SceneActor sceneActor){
ActorType actorType = sceneActor.getType();
CommonProto.SceneActor.Builder builder = CommonProto.SceneActor.newBuilder()
.setId(sceneActor.getId())
@ -22,7 +23,7 @@ public class BeanToProto {
.setType(actorType.getStateCode())
.setState(sceneActor.getStateType().getState());
if(actorType != ActorType.Npc){
builder.setCreature(getCreature((Creature)sceneActor));
builder.setCreature(getCreature(scene,(Creature)sceneActor));
}
if(actorType == ActorType.Player){
builder.setUserName(BattleManager.bloodMyHeroInfoMap.get(sceneActor.getId()).getName());
@ -30,7 +31,7 @@ public class BeanToProto {
return builder.build();
}
public static CommonProto.Creature getCreature(Creature creature){
public static CommonProto.Creature getCreature(Scene scene,Creature creature){
CommonProto.Creature.Builder builder = CommonProto.Creature.newBuilder();
if(creature.getType() == ActorType.Player){
UserBloodySnpInfo userBloodySnpInfo = BattleManager.bloodMyHeroInfoMap.get(creature.getId());
@ -43,6 +44,8 @@ public class BeanToProto {
Integer curHp = attribute.get(HeroAttributeEnum.CurHP.getPropertyId());
builder.addHeroInfo(CommonProto.BloodyHeroInfo.newBuilder().setHeroId(heroId).setHeroHp(curHp).setHeroMaxHp(hp).setHeroTid(familyHeroInfo.getTempleteId()));
}
AnalysisData analysisData = scene.getAnalysisData(creature.getId());
builder.setKillNums(analysisData.getKillNums());
}
if(creature.getStateType() != StateType.FROZEN){
builder.addAllPath(creature.getPath());
@ -50,7 +53,6 @@ public class BeanToProto {
return builder.setCurHp(creature.getLife().getCurHp())
.setMaxHp(creature.getLife().getMaxMp())
.setSpeed(creature.getSpeed())
.setCamp(creature.getCamp())
.setMineral(creature.getMineral())
.build();
@ -77,7 +79,7 @@ public class BeanToProto {
CommonProto.SceneInfo.Builder builder = CommonProto.SceneInfo.newBuilder().setMapId(scene.getMapId());
Map<Integer, SceneActor> sceneActorMap = scene.getSceneActorMap();
for(SceneActor sceneActor : sceneActorMap.values()){
builder.addSceneActor(getSceneActor(sceneActor));
builder.addSceneActor(getSceneActor(scene,sceneActor));
Map<Integer, EffectBuffer> bufferMap = sceneActor.getBufferMap();
Iterator<Map.Entry<Integer, EffectBuffer>> iterator = bufferMap.entrySet().iterator();
while (iterator.hasNext()){

View File

@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ScheduledThreadPoolExecutor;
@ -38,7 +39,41 @@ public class SceneManager {
private static Map<Integer, Scene> sceneMap = new HashMap<>();
private static Map<Integer, Scene> sceneByUidMap = new HashMap<>();
private static Map<Integer,Long> readyRunTaskMap = new ConcurrentHashMap<>();
private static ScheduledThreadPoolExecutor scheduledExecutor=new ScheduledThreadPoolExecutor(8); //管理task
static {
scheduledExecutor.execute(new Runnable() {
@Override
public void run() {
while (true){
try {
SBloodyBattleSetting sBloodyBattleSetting = SBloodyBattleSetting.sBloodyBattleSetting;
if(sBloodyBattleSetting != null){
long now = System.currentTimeMillis();
Iterator<Map.Entry<Integer, Long>> iterator = readyRunTaskMap.entrySet().iterator();
while (iterator.hasNext()){
Map.Entry<Integer, Long> next = iterator.next();
Integer roomId = next.getKey();
Long time = next.getValue();
if(time - now > sBloodyBattleSetting.getReloadTime() * 1000){
iterator.remove();
Scene scene = sceneMap.get(roomId);
if(scene!=null){
startGame(scene);
}
}
}
}
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
});
}
public static BloodyMap bloodyMap;
public static Queue<List<Integer>> possibalePositions = new LinkedBlockingDeque<>();
@ -397,15 +432,21 @@ public class SceneManager {
public static void startGame(Scene scene) {
for(SceneActor sceneActor : scene.getSceneActorMap().values()){
if(sceneActor.getType()== ActorType.Player){
MessageUtil.sendRoomStartGameIndication(sceneActor.getId());
synchronized (scene){
if(scene.getState() == 1){
return;
}
for(SceneActor sceneActor : scene.getSceneActorMap().values()){
if(sceneActor.getType()== ActorType.Player){
MessageUtil.sendRoomStartGameIndication(sceneActor.getId());
}
}
scene.setState(1);
scene.setStartTime(System.currentTimeMillis());
scheduledExecutor.execute(scene);
LOGGER.info("the roomid={},start battle pvp",scene.getRoomId());
}
scene.setState(1);
scene.setStartTime(System.currentTimeMillis());
scheduledExecutor.execute(scene);
LOGGER.info("the roomid={},start battle pvp",scene.getRoomId());
}
@ -415,4 +456,24 @@ public class SceneManager {
scene.getSceneActorMap().get(uid).setGameState(StateType.UNREADY_STATE);
}
}
static class ReadySceneTask{
private Scene scene;
private long startTime;
public ReadySceneTask(Scene scene, long startTime) {
this.scene = scene;
this.startTime = startTime;
}
public Scene getScene() {
return scene;
}
public long getStartTime() {
return startTime;
}
}
}

View File

@ -18,6 +18,7 @@ public class BattleAnalysisProcessor implements AnalysisProcessor{
}else{
analysisData.fail();
}
analysis(scene,analysisData,analysisSourceData);
}
@ -37,28 +38,21 @@ public class BattleAnalysisProcessor implements AnalysisProcessor{
String targetName = targetBloodySnpInfo.getName();
String casterName = casterBloodySnpInfo.getName();
scene.addCahceBroadMsg(MessageFormat.format(sBloodyMessagesConfig.getMessage(),new String[]{targetName,casterName}));
return;
}
}
return;
}
if(sBloodyMessagesConfig.getType() == AnalysisDataType.CONTINUOUS_KILL_NUMS.getType()){
if(sBloodyMessagesConfig.getType() == AnalysisDataType.CONTINUOUS_KILL_NUMS.getType() || sBloodyMessagesConfig.getType() == AnalysisDataType.CONTINUOUS_DIED_NUMS.getType()){
if(targetAnalysisData.getContinuousKillNums() == count){
int id = targetAnalysisData.getId();
UserBloodySnpInfo userBloodySnpInfo = BattleManager.bloodMyHeroInfoMap.get(id);
String name = userBloodySnpInfo.getName();
scene.addCahceBroadMsg(MessageFormat.format(sBloodyMessagesConfig.getMessage(),new String[]{name}));
return;
}
return;
}
if(sBloodyMessagesConfig.getType() == AnalysisDataType.CONTINUOUS_DIED_NUMS.getType()){
if(targetAnalysisData.getContinuousDeadNums() == count){
int id = targetAnalysisData.getId();
UserBloodySnpInfo userBloodySnpInfo = BattleManager.bloodMyHeroInfoMap.get(id);
String name = userBloodySnpInfo.getName();
scene.addCahceBroadMsg(MessageFormat.format(sBloodyMessagesConfig.getMessage(),new String[]{name}));
}
return;
}
if(sBloodyMessagesConfig.getType() == AnalysisDataType.END_CONTINUOUS_KILL_NUMS.getType()){
int targetId = analysisSourceData.getTargetId();
int casterId = analysisSourceData.getCaster();
@ -70,8 +64,9 @@ public class BattleAnalysisProcessor implements AnalysisProcessor{
String targetName = targetBloodySnpInfo.getName();
String casterName = casterBloodySnpInfo.getName();
scene.addCahceBroadMsg(MessageFormat.format(sBloodyMessagesConfig.getMessage(),new String[]{targetName,casterName}));
return;
}
return;
}
if(sBloodyMessagesConfig.getType() == AnalysisDataType.SEND_TO_DEATH.getType()){
if(targetAnalysisData.getContinuousDeadNums() >= count){
@ -79,8 +74,9 @@ public class BattleAnalysisProcessor implements AnalysisProcessor{
UserBloodySnpInfo userBloodySnpInfo = BattleManager.bloodMyHeroInfoMap.get(id);
String name = userBloodySnpInfo.getName();
scene.addCahceBroadMsg(MessageFormat.format(sBloodyMessagesConfig.getMessage(),new String[]{name}));
return;
}
return;
}
}

View File

@ -95,7 +95,6 @@ public class MessageUtil {
return;
}
int indicationIndex = session.getIndicationIndex();
System.out.println("indicationIndex----"+indicationIndex);
byte[] byteBuf = wrappedBuffer(session.getUid(), session.getToken(), indicationIndex,result, msgId, generatedMessage);
if (flush) {
session.writeAndFlush(byteBuf);

View File

@ -0,0 +1,56 @@
# redis config
# Redis数据库索引默认为0
spring.redis.database=2
#spring.redis.database=2
# Redis服务器地址
spring.redis.host=60.1.1.21
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码默认为空
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=0
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_50215_99991
#spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10212
mongodb.options.maxWaitTime = 120000
mongodb.options.connectTimeout = 1000
mongodb.options.socketTimeout = 0
mongodb.options.threadsAllowedToBlockForConnectionMultiplier = 20
mongodb.options.connectionsPerHost = 256
mongodb.options.minConnectionsPerHost = 5
mongodb.options.maxConnectionIdleTime = 1000
netty.tcpPort = 36080
netty.tcpIp = 60.1.1.215
netty.reconnectDelay=3000
netty.bossThreadCount=1
netty.workerThreadCount=10
netty.readTimeout=32
netty.writeTimeout=32
netty.allTimeout=35
#core
services.core.ip=60.1.1.215
services.core.port=27900
services.core.area=1000
services.core.id=1
services.core.weight=5
logging.config = conf/logback-boot.xml

View File

@ -0,0 +1,37 @@
# redis config
# Redis数据库索引默认为0
spring.redis.database=2
#spring.redis.database=2
# Redis服务器地址
spring.redis.host=60.1.1.21
# Redis服务器连接端口
spring.redis.port=6379
# Redis服务器连接密码默认为空
spring.redis.password=
# 连接池最大连接数(使用负值表示没有限制)
spring.redis.pool.max-active=8
# 连接池最大阻塞等待时间(使用负值表示没有限制)
spring.redis.pool.max-wait=-1
# 连接池中的最大空闲连接
spring.redis.pool.max-idle=8
# 连接池中的最小空闲连接
spring.redis.pool.min-idle=0
# 连接超时时间(毫秒)
spring.redis.timeout=0
#core
services.core.ip=60.1.1.215
services.core.port=17900
services.core.area=1000
services.core.id=1
services.core.weight=5
logging.config = conf/logback-boot.xml

View File

@ -1,6 +1,9 @@
package com.ljsd;
import com.google.gson.Gson;
import com.ljsd.jieling.config.CoreSettings;
import com.ljsd.jieling.config.ServerInfo;
import com.ljsd.jieling.redis.RedisKey;
import com.ljsd.jieling.redis.RedisUtil;
import com.ljsd.jieling.thrift.RPCServerTask;
import com.ljsd.jieling.thrift.pool.ThriftPoolUtils;
@ -17,6 +20,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
public class MatchServerApplication {
public static int arenId = 0;
private static Gson gson = new Gson();
public static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(MatchServerApplication.class);
springApplication.setRegisterShutdownHook(false);
@ -27,5 +31,17 @@ public class MatchServerApplication {
new RPCServerTask(configurableApplicationContext).start();
CoreSettings bean = configurableApplicationContext.getBean(CoreSettings.class);
arenId = bean.getArea();
register(configurableApplicationContext);
}
public static void register(ConfigurableApplicationContext configurableApplicationContext){
CoreSettings coreSettings = configurableApplicationContext.getBean(CoreSettings.class);
String ip = coreSettings.getIp();
int port = coreSettings.getPort();
int area = coreSettings.getArea();
String rpcUrl = ip + ":" + port;
RedisUtil.getInstence().sadd(RedisKey.MATCH_SERVER_INFO + ":" + area,gson.toJson(rpcUrl));
RedisUtil.getInstence().set( RedisKey.MATCH_SIZE + ":" + area,Integer.toString(1));
}
}

View File

@ -14,6 +14,10 @@ public class ServerInfo {
this.rpcUrl = rpcUrl;
}
public ServerInfo(String rpcUrl) {
this.rpcUrl = rpcUrl;
}
public String getUserSeeUrl() {
return userSeeUrl;
}

View File

@ -42,7 +42,7 @@ public class BloodyBattleReallyMatchServer implements IMatch{
/**
*
*/
private static int NEED_MATCH_PLAYER_COUNT = 0;
private static int NEED_MATCH_PLAYER_COUNT = 1;
/**
*
*/
@ -66,6 +66,7 @@ public class BloodyBattleReallyMatchServer implements IMatch{
LOGGER.info("执行匹配开始");
try{
//先把匹配池中的玩家按分数分布
NEED_MATCH_PLAYER_COUNT =Integer.parseInt(RedisUtil.getInstence().get(RedisKey.MATCH_SIZE + ":" + MatchServerApplication.arenId).toString());
TreeMap<Integer,HashSet<MatchPoolPlayerInfo>> pointMap = new TreeMap<Integer,HashSet<MatchPoolPlayerInfo>>();
for (MatchPoolPlayerInfo matchPlayer : playerPool.values()) {
//在匹配池中是时间太长,直接移除

View File

@ -10,5 +10,7 @@ public class RedisKey {
public static final String BLOODY_ROOM_ADDRESS = "BLOODY_ROOM_ADDRESS"; //房间服务器地址信息
public static final String USER_LOGIN_URL = "USER_LOGIN_URL"; //房间服务器地址信息
public static final String BLOODY_SERVER_INFO = "BLOODY_SERVER_INFO"; //房间服务器地址信息
public static final String MATCH_SERVER_INFO = "MATCH_SERVER_INFO"; //匹配服务器地址信息
public static final String MATCH_SIZE = "MATCH_SIZE"; //匹配人数设置
}

View File

@ -132,6 +132,16 @@ public class RedisUtil {
}
public boolean sadd(String key,String member){
try {
redisTemplate.opsForSet().add(key,member);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}

View File

@ -2,6 +2,7 @@ package com.ljsd;
import com.ljsd.common.mogodb.util.MongoKeys;
import com.ljsd.jieling.config.ServerConfig;
import com.ljsd.jieling.config.json.CoreSettings;
import com.ljsd.jieling.config.json.ServerConfiguration;
import com.ljsd.jieling.config.json.ServerProperties;
import com.ljsd.jieling.db.mongo.MongoUtil;
@ -66,7 +67,8 @@ public class GameApplication {
ServerConfiguration serverConfiguration = configurableApplicationContext.getBean(ServerConfiguration.class);
serverProperties = serverConfiguration.getServerProperties();
serverId = serverProperties.getId();
areaId = serverProperties.getId();
CoreSettings coreSettings = configurableApplicationContext.getBean(CoreSettings.class);
GameApplication.areaId = coreSettings.getArea();
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
RedisUtil.getInstence().init(configurableApplicationContext);
MongoUtil.getInstence().init(configurableApplicationContext);

View File

@ -85,6 +85,8 @@ public class SBloodyBattleSetting implements BaseConfig {
private int[][] scoreConversion;
private int reloadTime;
@Override
public void init() throws Exception {
@ -292,4 +294,8 @@ public class SBloodyBattleSetting implements BaseConfig {
public int[][] getScoreConversion() {
return scoreConversion;
}
public int getReloadTime() {
return reloadTime;
}
}

View File

@ -166,6 +166,7 @@ public class RedisKey {
public static final String BLOODY_TEAM = "BLOODY_TEAM";
public static final String BLOODY_SERVER_INFO = "BLOODY_SERVER_INFO";
public static final String BLOODY_PERSON_BATTLE_INFO = "BLOODY_PERSON_BATTLE_INFO";
public static final String MATCH_SERVER_INFO = "MATCH_SERVER_INFO";
public static String getKey(String type, String key, boolean withoutServerId) {
if(RedisKey.TOKEN.equals(type)||RedisKey.USER_SERVER_INFO.equals(type)){

View File

@ -876,6 +876,26 @@ public class RedisUtil {
}
}
public <T> List<T> getAllSetToList(String key, Class<T> clazz){
for(int i=0;i<MAX_TRY_TIMES;i++){
try {
Set<String> members = redisTemplate.opsForSet().members(key);
if(members!=null && !members.isEmpty()){
List<T> result = new ArrayList<>(members.size());
for(String item : members){
result.add(gson.fromJson(item,clazz));
}
return result;
}
} catch (Exception e) {
TimeUtils.sleep(FAILED_SLEEP);
}
}
return null;
}
public boolean sremove(String key,String member){
try {
redisTemplate.opsForSet().remove(key,member);

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.handler.room;
import com.google.gson.Gson;
import com.ljsd.GameApplication;
import com.ljsd.jieling.bloody.UserBloodySnpInfo;
import com.ljsd.jieling.config.SBloodyBattleSetting;
import com.ljsd.jieling.core.GlobalsDef;
@ -22,11 +23,13 @@ import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.protocols.RoomProto;
import com.ljsd.jieling.thrift.pool.ServiceKey;
import com.ljsd.jieling.util.MathUtils;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.StringUtil;
import com.ljsd.jieling.util.TimeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.monitor.ServerInfo;
import org.springframework.stereotype.Component;
import java.util.Calendar;
@ -73,7 +76,16 @@ public class RoomMatchRequestHandler extends BaseHandler{
User user = UserManager.getUser(iSession.getUid());
snapUserFightInfo(user);
RedisUtil.getInstence().set(RedisKey.MATCH_UID_KEY + ":" + uid,gson.toJson("1"));
String serviceKey =StringUtil.getServiceKey(ServiceKey.RPCMATCH,"60.1.1.215","17900");
List<String> matchAddressInfos = RedisUtil.getInstence().getAllSetToList(RedisKey.MATCH_SERVER_INFO + ":" + GameApplication.areaId, String.class);
if(matchAddressInfos == null || matchAddressInfos.isEmpty()){
LOGGER.error("没有匹配服务器");
MessageUtil.sendErrorResponse(iSession,0,responseMsgId,"没有匹配服务器");
return;
}
String rpcUrl = matchAddressInfos.get(MathUtils.randomInt(matchAddressInfos.size()));
String ip = rpcUrl.split(":")[0];
String port = rpcUrl.split(":")[1];
String serviceKey =StringUtil.getServiceKey(ServiceKey.RPCMATCH,ip,port);
ClientAdapterPo<RPCMatchRequestIFace.Client> rPCClient = null;
try {
rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey);
@ -93,8 +105,8 @@ public class RoomMatchRequestHandler extends BaseHandler{
public static void snapUserFightInfo(User mine){
//血量处理
// int myteamId = GlobalsDef.BLOODY_TEAM;
int myteamId = 1;
int myteamId = GlobalsDef.BLOODY_TEAM;
mine.getTeamPosManager().setCurTeamPosId(myteamId);
PlayerManager playerInfoManager = mine.getPlayerInfoManager();
UserBloodySnpInfo userBloodySnpInfo = new UserBloodySnpInfo(mine.getId(),playerInfoManager.getNickName());

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.thread.task;
import com.google.gson.Gson;
import com.ljsd.CoreService;
import com.ljsd.GameApplication;
import com.ljsd.jieling.config.json.CoreSettings;
import com.ljsd.jieling.thrift.idl.RPCRequestIFace;
import org.apache.thrift.TProcessor;