Merge branch 'online_1121'
# Conflicts: # serverlogic/src/main/java/com/ljsd/jieling/network/server/ProtocolsManager.javaback_recharge
commit
1bc50cff0c
|
@ -0,0 +1,25 @@
|
|||
package com.ljsd.jieling.kefu;
|
||||
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.logic.dao.Equip;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Cmd_fixEquip extends GmAbstract{
|
||||
@Override
|
||||
public boolean exec(String[] args) throws Exception {
|
||||
List<User> userList = MongoUtil.getInstence().getMyMongoTemplate().findAll(User.getCollectionName(), User.class);
|
||||
userList.forEach(user -> {
|
||||
user.getEquipManager().getEquipMap().values().forEach(equip -> equip.setHeroId(""));
|
||||
Map<String, Equip> equipMap = user.getEquipManager().getEquipMap();
|
||||
user.getHeroManager().getHeroMap().values().forEach(hero -> {
|
||||
Map<Integer, String> equipByPositionMap = hero.getEquipByPositionMap();
|
||||
equipByPositionMap.values().forEach(equipId -> equipMap.get(equipId).setHeroId(hero.getId()));
|
||||
});
|
||||
});
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -835,11 +835,9 @@ public class GuildLogic {
|
|||
return;
|
||||
}
|
||||
MailLogic.getInstance().sendMail(uid,title,content,"",(int) (TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
|
||||
ISession session = OnlineUserManager.getSessionByUid(uid);
|
||||
if(session!=null){
|
||||
Family.FamilyPositionUpdateIndication build = Family.FamilyPositionUpdateIndication.newBuilder().setPostiion(position).build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.FAMILY_POSITION_UPDATE_INDICAITON_VALUE,build,true);
|
||||
}
|
||||
Family.FamilyPositionUpdateIndication build = Family.FamilyPositionUpdateIndication.newBuilder().setPosition(position).setUid(uid).build();
|
||||
User userInMem = UserManager.getUserInMem(uid);
|
||||
sendIndicationToMember(GuilidManager.guildInfoMap.get(userInMem.getPlayerInfoManager().getGuildId()), MessageTypeProto.MessageType.FAMILY_POSITION_UPDATE_INDICAITON,build);
|
||||
}
|
||||
|
||||
public static void sendFamilyBaseUpdateIndication(GuildInfo guildInfo){
|
||||
|
|
|
@ -1436,7 +1436,7 @@ public class HeroLogic{
|
|||
if( null == equip || null == hero ){
|
||||
return false;
|
||||
}
|
||||
if(!StringUtil.isEmpty(equip.getHeroId())){
|
||||
if(!StringUtil.isEmpty(equip.getHeroId()) && !equip.getHeroId().equals(hero.getId())){
|
||||
return false;
|
||||
}
|
||||
int equipIdTid = equip.getEquipId();
|
||||
|
@ -1465,11 +1465,18 @@ public class HeroLogic{
|
|||
Hero hero = user.getHeroManager().getHeroMap().get(heroId);
|
||||
if(type==1){
|
||||
Map<Integer,String> equipInfoTmp = new HashMap<>(6);
|
||||
EquipManager equipManager = user.getEquipManager();
|
||||
if(!checkEquipForWear(hero,user.getEquipManager(),equipIds,equipInfoTmp)){
|
||||
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR);
|
||||
}
|
||||
hero.getEquipByPositionMap().forEach((Integer position,String equipId) -> {
|
||||
if(equipInfoTmp.containsKey(position) && !equipId.equals(equipInfoTmp.get(position))){
|
||||
equipManager.getEquipMap().get(equipId).setHeroId("");
|
||||
}
|
||||
});
|
||||
hero.updateMutliEquipPositionMap(equipInfoTmp);
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.WEAR_EQUIP,equipInfoTmp.size());
|
||||
equipIds.forEach(equipId->equipManager.getEquipMap().get(equipId).setHeroId(heroId));
|
||||
}else if(type ==2){
|
||||
if(equipIds.size()!=1){
|
||||
throw new ErrorCodeException(ErrorCode.HERO_OPT_ONE);
|
||||
|
@ -1633,9 +1640,10 @@ public class HeroLogic{
|
|||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
List<Integer> positions = new ArrayList<>();
|
||||
Map<String, Equip> equipMap = user.getEquipManager().getEquipMap();
|
||||
for(String equipId : equipIds){
|
||||
Equip equip = user.getEquipManager().getEquipMap().get(equipId);
|
||||
if(null == equip || !StringUtil.isEmpty(equip.getHeroId())){
|
||||
Equip equip = equipMap.get(equipId);
|
||||
if(null == equip || StringUtil.isEmpty(equip.getHeroId())){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int equipIdTid = equip.getEquipId();
|
||||
|
@ -1643,6 +1651,7 @@ public class HeroLogic{
|
|||
int position = sEquipConfig.getPosition();
|
||||
positions.add(position);
|
||||
}
|
||||
equipIds.forEach(equidId->equipMap.get(equidId).setHeroId(""));
|
||||
|
||||
for(Integer position : positions){
|
||||
hero.removeEquip(position);
|
||||
|
|
|
@ -28,6 +28,7 @@ import config.*;
|
|||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -463,6 +464,9 @@ public class WorkShopLogic {
|
|||
costResult = false;
|
||||
break;
|
||||
}
|
||||
if(!StringUtil.isEmpty(consumeEquip.getHeroId())){
|
||||
return "祭品已经被穿戴";
|
||||
}
|
||||
SEquipConfig consumeSEquipConfig = STableManager.getConfig(SEquipConfig.class).get(consumeEquip.getEquipId());
|
||||
if(consumeSEquipConfig.getQuality()!=mainCostQuality[0]){
|
||||
costResult = false;
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.ljsd.jieling.util.MessageUtil;
|
|||
session.setUserLoginTime(System.currentTimeMillis() / 1000);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -86,96 +86,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
|
||||
|
||||
public void processMessage(PacketNetData packetNetData) {
|
||||
//
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
// if (!GameApplication.start) {
|
||||
// return;
|
||||
// }
|
||||
// final ISession session = (ISession) gameSession;
|
||||
// PacketNetData packetNetData = new PacketNetData((byte[]) obj);
|
||||
// int msgId = packetNetData.getMsgId();
|
||||
//// LOGGER.info("uid={},msgId={},index={}",packetNetData.getUserId(),msgId,packetNetData.getIndex());
|
||||
//// MessageTypeProto.MessageType messageType = MessageTypeProto.MessageType.valueOf(msgId);
|
||||
//// FileWriter fw = null;
|
||||
//// if (!gameMessageForLogin.containsKey(messageType)){
|
||||
//// gameMessageForLogin.put(messageType,messageType + "=" + gson.toJson(obj));
|
||||
//// try {
|
||||
//// fw = new FileWriter("tmp/1.txt",true);
|
||||
//// fw.write(messageType + "=" + gson.toJson(obj));
|
||||
//// fw.write("\r\n");
|
||||
//// fw.flush();
|
||||
//// } catch (IOException e) {
|
||||
//// e.printStackTrace();
|
||||
//// try {
|
||||
//// fw.close();
|
||||
//// } catch (IOException e1) {
|
||||
//// e1.printStackTrace();
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// if (packetNetData.getMsgId() ==MessageTypeProto.MessageType.GET_FRIEND_INFO_REQUEST_VALUE ){
|
||||
//// try {
|
||||
//// if (fw != null){
|
||||
//// fw.close();
|
||||
//// }
|
||||
//// } catch (IOException e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
//// }
|
||||
// if (packetNetData.getMsgId()==1000){
|
||||
// dealHeartBeat(session);
|
||||
// return;
|
||||
// }
|
||||
// LOGGER.info("request={} commond ={}: " ,packetNetData.getUserId(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
// if (packetNetData.getMsgId()== MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE ||
|
||||
// packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
//
|
||||
// //初始化session
|
||||
// if (!sessionInit(session,packetNetData)){
|
||||
// serverKick(session,"您的账号token不正确,请退出游戏重新登陆!");
|
||||
// return;
|
||||
// }
|
||||
// //处理多设备重登
|
||||
// dealRepeatLogin(session);
|
||||
// /* if(== 1 && packetNetData.getMsgId()!= MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
// return;
|
||||
// }*/
|
||||
// //刷新token
|
||||
// //refreshToken(session);
|
||||
// //踢下线
|
||||
// //在线列表加入session
|
||||
// OnlineUserManager.userOnline(session.getUid(),session);
|
||||
// }
|
||||
// if(packetNetData.getMsgId() == MessageTypeProto.MessageType.ACK_INDICATION_REQUEST_VALUE){
|
||||
// ackIndication(session,packetNetData.getIndex());
|
||||
// return;
|
||||
// }
|
||||
// //处理心跳
|
||||
// if (packetNetData.getMsgId()==1000){
|
||||
// dealHeartBeat(session);
|
||||
// return;
|
||||
// }
|
||||
// //检查token
|
||||
// if (checkToken(session,packetNetData) != 0 ){
|
||||
// serverKick(session,"您的账号token不正确,请退出游戏重新登陆!");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if( packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
// processReconnect(session);
|
||||
// LOGGER.info("the uid={} process reconnect",session.getUid());
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (checkIndex(session,packetNetData) != 0){
|
||||
// return;
|
||||
// }
|
||||
// boolean b = Blocker.checkForbidUser(session);
|
||||
// if(b){
|
||||
// return;
|
||||
// }
|
||||
//>>>>>>> 843e4f921d5bc65ced6568bf5fc4b58b2b17cf54
|
||||
BaseHandler baseHandler = handlers.get(packetNetData.getMsgId());
|
||||
if (baseHandler == null) {
|
||||
LOGGER.info("request unknow commond : " + packetNetData.getMsgId());
|
||||
|
@ -204,496 +114,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
}
|
||||
|
||||
|
||||
//<<<<<<< HEAD
|
||||
////<<<<<<< HEAD
|
||||
////=======
|
||||
//// public void processReconnect(ISession session) {
|
||||
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
//// Type type = new TypeToken<Map<Integer, ISession.IndicationMsg>>(){}.getType();
|
||||
//// Object indicationInRedis = RedisUtil.getInstence().get(key);
|
||||
//// int maxMsgId = 1;
|
||||
//// if(indicationInRedis!=null){
|
||||
//// Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
|
||||
//// for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
|
||||
//// session.writeAndFlush(info.getValue().getMsg());
|
||||
//// session.putBackIndicationToMap(info.getKey(),info.getValue().getMsg());
|
||||
//// if(info.getKey()>maxMsgId){
|
||||
//// maxMsgId = info.getKey();
|
||||
//// }
|
||||
//=======
|
||||
// public void processReconnect(ISession session) {
|
||||
// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
// Type type = new TypeToken<Map<Integer, ISession.IndicationMsg>>(){}.getType();
|
||||
// Object indicationInRedis = RedisUtil.getInstence().get(key);
|
||||
// int maxMsgId = 1;
|
||||
// if(indicationInRedis!=null){
|
||||
// Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
|
||||
// for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
|
||||
// session.writeAndFlush(info.getValue().getMsg());
|
||||
// session.putBackIndicationToMap(info.getKey(),info.getValue().getMsg());
|
||||
// if(info.getKey()>maxMsgId){
|
||||
// maxMsgId = info.getKey();
|
||||
// }
|
||||
// }
|
||||
// RedisUtil.getInstence().del(key);
|
||||
// }
|
||||
// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
// type = new TypeToken<Map<Integer, byte[]>>(){}.getType();
|
||||
// Object responsInRedis = RedisUtil.getInstence().get(key);
|
||||
// session.setFiveReady(1);
|
||||
// String indicationIndexInRedisKey = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
// String indicationIndexInRedis =(String) RedisUtil.getInstence().get(indicationIndexInRedisKey);
|
||||
// if(!StringUtil.isEmpty(indicationIndexInRedis)){
|
||||
// maxMsgId= Integer.parseInt(indicationIndexInRedis);
|
||||
// }
|
||||
//
|
||||
// session.updateIndicationIndex(maxMsgId);
|
||||
// if(responsInRedis!=null){
|
||||
// Map<Integer, byte[]> response = gson.fromJson(responsInRedis.toString(), type);
|
||||
// if(response!=null && !response.isEmpty()){
|
||||
// session.setIndexToMessage(new ConcurrentHashMap<Integer, byte[]> (response));
|
||||
// Integer index = response.keySet().iterator().next();
|
||||
// session.setIndex(index);
|
||||
// RedisUtil.getInstence().del(key);
|
||||
// LOGGER.info("the uid={} cache repsponse is ={},session={}",session.getUid(),index,session.getCtx().channel());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// LOGGER.info("the uid={} reconnect,the maxid={} ",session.getUid(),maxMsgId);
|
||||
// User userInMem = UserManager.getUserInMem(session.getUid());
|
||||
// if(userInMem!=null){
|
||||
// ActivityLogic.getInstance().updateActivityMissionProgress(userInMem, ActivityType.OnlineReward,0);
|
||||
// try {
|
||||
// StoreLogic.checkStoreRefresh(userInMem,userInMem.getStoreManager().getStoreInfoMap());
|
||||
// GlobalDataManaager.checkNeedReFlush(session, userInMem, PlayerInfoProto.FivePlayerUpdateIndication.newBuilder());
|
||||
// List<CommonProto.Item> allItemList = ItemUtil.getAllItem(userInMem,false);
|
||||
// if(!allItemList.isEmpty()){
|
||||
// PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(allItemList).setType(0).build();
|
||||
// MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
|
||||
// }
|
||||
// if(userInMem.getMapManager().getEndlessMapInfo().getSeason()!=MapLogic.getEndlessSeason()){
|
||||
// MapLogic.getInstance().endLessClear(session);
|
||||
// }
|
||||
// MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
// } catch (Exception e) {
|
||||
// LOGGER.error("the uid={} processFlush wrong ,e={}",session.getUid(),e);
|
||||
// }
|
||||
// }
|
||||
// MessageUtil.sendMessageWithoutBack(session,1, MessageTypeProto.MessageType.RECONNECT_RESPONSE_VALUE,null,true);
|
||||
// }
|
||||
//
|
||||
// private boolean sessionInit(ISession session, PacketNetData packetNetData) {
|
||||
// int uid = packetNetData.getUserId();
|
||||
// int token = packetNetData.getToken();
|
||||
// session.setUid(uid);
|
||||
// String tokenKey = RedisKey.getKey(RedisKey.TOKEN, String.valueOf(uid),false);
|
||||
// if(null==tokenKey||tokenKey.isEmpty()){
|
||||
// return false;
|
||||
// }
|
||||
// String tokenK = (String)RedisUtil.getInstence().get(tokenKey);
|
||||
// if(null==tokenK||tokenK.isEmpty()){
|
||||
// return false;
|
||||
// }
|
||||
// int serverToken = Integer.parseInt((String)RedisUtil.getInstence().get(tokenKey));
|
||||
// if (token == serverToken){
|
||||
// session.setToken(token);
|
||||
// session.setUserLoginTime(System.currentTimeMillis()/1000);
|
||||
// return true;
|
||||
// }
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private int dealRepeatLogin(ISession newSession) {
|
||||
// int uid = newSession.getUid();
|
||||
// if (OnlineUserManager.checkUidOnline(uid)){
|
||||
// ISession iSession = OnlineUserManager.getSessionByUid(uid);
|
||||
// if(iSession == newSession){
|
||||
// return 0;
|
||||
// }
|
||||
// serverKick(iSession,"您的账号已经在其他设备上登陆,请确认账号安全!");
|
||||
// return 1;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// private int checkIndex(ISession iSession, PacketNetData packetNetData) {
|
||||
// /* if(packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE || packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
// return 0;
|
||||
// }*/
|
||||
// int index = packetNetData.getIndex();
|
||||
// if (iSession.getIndex() >= index){
|
||||
// byte[] message = iSession.getCacheMessage(index);
|
||||
// if (message==null){
|
||||
// //TODO error
|
||||
// LOGGER.info("the uid={},the msg={} is processing,the index={},the sessionIndex={}",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()),index,iSession.getIndex());
|
||||
// return 1;
|
||||
// }else {
|
||||
// LOGGER.info("the uid={},the msg={} reback",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
// iSession.writeAndFlush(message);
|
||||
// return 1;
|
||||
// }
|
||||
// }else {
|
||||
// iSession.setIndex(index);
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
// private void ackIndication(ISession iSession, int ackId) {
|
||||
// LOGGER.info("the uid={},the ackId={}",iSession.getUid(),ackId);
|
||||
// iSession.clearIndication(ackId);
|
||||
// MessageUtil.sendAck(iSession,ackId);
|
||||
// }
|
||||
//
|
||||
// private void dealHeartBeat(ISession session) {
|
||||
// session.setHeartBreatNums(3);
|
||||
// MessageUtil.sendHeartBeat(session);
|
||||
// }
|
||||
//
|
||||
// private int checkToken(ISession session, PacketNetData packetNetData) {
|
||||
// if (session.getToken() != packetNetData.getToken()){
|
||||
// return 1;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Override
|
||||
// public void offLine(GameSession gameSession) {
|
||||
//
|
||||
// ISession session = (ISession) gameSession;
|
||||
// LOGGER.info("player offLine ..{}",session.getUid());
|
||||
// synchronized (session) {
|
||||
// if (session.getUid() == 0) {
|
||||
// LOGGER.error("offLine->uid={}", session.getUid());
|
||||
// return;
|
||||
// }
|
||||
// if(session.getOfflineType() == ErrorCode.reloginCode){
|
||||
// return;
|
||||
// }
|
||||
// User user = UserManager.getUserInMem(session.getUid());
|
||||
// if(user == null){
|
||||
// LOGGER.info("the uid={},not in mem",session.getUid());
|
||||
// return;
|
||||
// }
|
||||
// KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,1);
|
||||
// KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
|
||||
// LOGGER.info("player={} offLine ...",user.getId());
|
||||
// OnlineUserManager.userOffline(session.getUid());
|
||||
// if (session.getCtx() != null) {
|
||||
// GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
||||
// }
|
||||
//
|
||||
// GameMessageHandler.currentSessions.remove(session.getUid());
|
||||
// processUserOfflineData(user,session);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void processUserOfflineData(User user,ISession session){
|
||||
// try {
|
||||
// GuildLogic.updateMyPos(user);
|
||||
// if(session.getFiveReady()==1){
|
||||
// PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
// playerInfoManager.setOffLineTime(TimeUtils.now());
|
||||
// long onlineTime = playerInfoManager.getOffLineTime() - session.getLoginTime();
|
||||
// playerInfoManager.addOnlineTime(onlineTime);
|
||||
// //更新在线时长
|
||||
// ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
|
||||
// MongoUtil.getInstence().lastUpdate();
|
||||
// session.setFiveReady(0);
|
||||
// }
|
||||
// backUpMsgToRedis(session);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// } finally {
|
||||
// //保证数据的保存
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void backUpMsgToRedis(ISession session){
|
||||
// ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
// LOGGER.info("the uid={} offline.the indication size={}",session.getUid(),indexToIndication.size());
|
||||
// if(!indexToIndication.isEmpty() ){
|
||||
// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
// RedisUtil.getInstence().set(key,gson.toJson(indexToIndication));
|
||||
// }
|
||||
// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
// RedisUtil.getInstence().set(key,String.valueOf(session.getIndicationIndex()));
|
||||
//
|
||||
// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
// RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
|
||||
// }
|
||||
|
||||
//
|
||||
// public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
|
||||
// if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
|
||||
// if (requestTime != 0 && requestTime < GameMessageHandler.currentSessions.get(uid).getUserLoginTime()) {
|
||||
// LOGGER.info("kickOldUser->uid={},requestTime={},userLoginTime={}",
|
||||
// uid, requestTime, GameMessageHandler.currentSessions.get(uid).getUserLoginTime());
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!OnlineUserManager.checkUidOnline(uid)) {
|
||||
// LOGGER.info("kickOldUser->uid={};isNotOnline", uid);
|
||||
// return false;
|
||||
// }
|
||||
// ISession oldSession = OnlineUserManager.getSessionByUid(uid);
|
||||
// if (oldSession == null) {
|
||||
// LOGGER.info("kickOldUser->uid={};oldSessionisNull", uid);
|
||||
// OnlineUserManager.userOffline(uid);
|
||||
// return false;
|
||||
// }
|
||||
// oldSession.setOfflineType(errorCode);
|
||||
//
|
||||
//// if (oldSession.getCtx() != null && !uToken.equals(oldSession.getToken())) {
|
||||
//// Channel oldChannl = oldSession.getCtx().channel();
|
||||
//// if (errorCode == ErrorCode.LOGIN_IN_OTHER_GAMESERVER) {
|
||||
//// OnlineUserLogics.removeFromOnline(uid);
|
||||
//// //转化为踢人消息,
|
||||
//// // 如果当前设备重新登录或重连,登录的其他服务器
|
||||
//// // 那么当前连接应该已经断开,客户端不会收到该消息,则当前设备不会被踢下线
|
||||
//// //如果用其他设备登录,则当前设备能够收到这条消息,则当前设备被踢下线
|
||||
//// errorCode = ErrorCode.LOGIN_IN_OTHER;
|
||||
//>>>>>>> 3c59042b88571e9eaa811ea7140537965aeac324
|
||||
//// }
|
||||
//// RedisUtil.getInstence().del(key);
|
||||
//// }
|
||||
//// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
//// type = new TypeToken<Map<Integer, byte[]>>(){}.getType();
|
||||
//// Object responsInRedis = RedisUtil.getInstence().get(key);
|
||||
//// session.setFiveReady(1);
|
||||
//// String indicationIndexInRedisKey = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
//// String indicationIndexInRedis =(String) RedisUtil.getInstence().get(indicationIndexInRedisKey);
|
||||
//// if(!StringUtil.isEmpty(indicationIndexInRedis)){
|
||||
//// maxMsgId= Integer.parseInt(indicationIndexInRedis);
|
||||
//// }
|
||||
////
|
||||
//// session.updateIndicationIndex(maxMsgId);
|
||||
//// if(responsInRedis!=null){
|
||||
//// Map<Integer, byte[]> response = gson.fromJson(responsInRedis.toString(), type);
|
||||
//// if(response!=null && !response.isEmpty()){
|
||||
//// session.setIndexToMessage(new ConcurrentHashMap<Integer, byte[]> (response));
|
||||
//// Integer index = response.keySet().iterator().next();
|
||||
//// session.setIndex(index);
|
||||
//// RedisUtil.getInstence().del(key);
|
||||
//// LOGGER.info("the uid={} cache repsponse is ={},session={}",session.getUid(),index,session.getCtx().channel());
|
||||
//// }
|
||||
////
|
||||
//// }
|
||||
//// LOGGER.info("the uid={} reconnect,the maxid={} ",session.getUid(),maxMsgId);
|
||||
//// User userInMem = UserManager.getUserInMem(session.getUid());
|
||||
//// if(userInMem!=null){
|
||||
//// ActivityLogic.getInstance().updateActivityMissionProgress(userInMem, ActivityType.OnlineReward,0);
|
||||
//// try {
|
||||
//// StoreLogic.checkStoreRefresh(userInMem,userInMem.getStoreManager().getStoreInfoMap());
|
||||
//// GlobalDataManaager.checkNeedReFlush(session, userInMem, PlayerInfoProto.FivePlayerUpdateIndication.newBuilder());
|
||||
//// List<CommonProto.Item> allItemList = ItemUtil.getAllItem(userInMem,false);
|
||||
//// if(!allItemList.isEmpty()){
|
||||
//// PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(allItemList).setType(0).build();
|
||||
//// MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
|
||||
//// }
|
||||
//// MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
//// } catch (Exception e) {
|
||||
//// LOGGER.error("the uid={} processFlush wrong ,e={}",session.getUid(),e);
|
||||
//// }
|
||||
//// }
|
||||
//// MessageUtil.sendMessageWithoutBack(session,1, MessageTypeProto.MessageType.RECONNECT_RESPONSE_VALUE,null,true);
|
||||
//// }
|
||||
////
|
||||
//// private boolean sessionInit(ISession session, PacketNetData packetNetData) {
|
||||
//// int uid = packetNetData.getUserId();
|
||||
//// int token = packetNetData.getToken();
|
||||
//// session.setUid(uid);
|
||||
//// String tokenKey = RedisKey.getKey(RedisKey.TOKEN, String.valueOf(uid),false);
|
||||
//// if(null==tokenKey||tokenKey.isEmpty()){
|
||||
//// return false;
|
||||
//// }
|
||||
//// String tokenK = (String)RedisUtil.getInstence().get(tokenKey);
|
||||
//// if(null==tokenK||tokenK.isEmpty()){
|
||||
//// return false;
|
||||
//// }
|
||||
//// int serverToken = Integer.parseInt((String)RedisUtil.getInstence().get(tokenKey));
|
||||
//// if (token == serverToken){
|
||||
//// session.setToken(token);
|
||||
//// session.setUserLoginTime(System.currentTimeMillis()/1000);
|
||||
//// return true;
|
||||
//// }
|
||||
//// return true;
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// private int dealRepeatLogin(ISession newSession) {
|
||||
//// int uid = newSession.getUid();
|
||||
//// if (OnlineUserManager.checkUidOnline(uid)){
|
||||
//// ISession iSession = OnlineUserManager.getSessionByUid(uid);
|
||||
//// if(iSession == newSession){
|
||||
//// return 0;
|
||||
//// }
|
||||
//// serverKick(iSession,"您的账号已经在其他设备上登陆,请确认账号安全!");
|
||||
//// return 1;
|
||||
//// }
|
||||
//// return 0;
|
||||
//// }
|
||||
////
|
||||
//// private int checkIndex(ISession iSession, PacketNetData packetNetData) {
|
||||
//// /* if(packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE || packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
|
||||
//// return 0;
|
||||
//// }*/
|
||||
//// int index = packetNetData.getIndex();
|
||||
//// if (iSession.getIndex() >= index){
|
||||
//// byte[] message = iSession.getCacheMessage(index);
|
||||
//// if (message==null){
|
||||
//// //TODO error
|
||||
//// LOGGER.info("the uid={},the msg={} is processing,the index={},the sessionIndex={}",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()),index,iSession.getIndex());
|
||||
//// return 1;
|
||||
//// }else {
|
||||
//// LOGGER.info("the uid={},the msg={} reback",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
//// iSession.writeAndFlush(message);
|
||||
//// return 1;
|
||||
//// }
|
||||
//// }else {
|
||||
//// iSession.setIndex(index);
|
||||
//// }
|
||||
//// return 0;
|
||||
//// }
|
||||
////
|
||||
//// private void ackIndication(ISession iSession, int ackId) {
|
||||
//// LOGGER.info("the uid={},the ackId={}",iSession.getUid(),ackId);
|
||||
//// iSession.clearIndication(ackId);
|
||||
//// MessageUtil.sendAck(iSession,ackId);
|
||||
//// }
|
||||
////
|
||||
//// private void dealHeartBeat(ISession session) {
|
||||
//// session.setHeartBreatNums(3);
|
||||
//// MessageUtil.sendHeartBeat(session);
|
||||
//// }
|
||||
////
|
||||
//// private int checkToken(ISession session, PacketNetData packetNetData) {
|
||||
//// if (session.getToken() != packetNetData.getToken()){
|
||||
//// return 1;
|
||||
//// }
|
||||
//// return 0;
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// @Override
|
||||
//// public void offLine(GameSession gameSession) {
|
||||
////
|
||||
//// ISession session = (ISession) gameSession;
|
||||
//// LOGGER.info("player offLine ..{}",session.getUid());
|
||||
//// synchronized (session) {
|
||||
//// if (session.getUid() == 0) {
|
||||
//// LOGGER.error("offLine->uid={}", session.getUid());
|
||||
//// return;
|
||||
//// }
|
||||
//// if(session.getOfflineType() == ErrorCode.reloginCode){
|
||||
//// return;
|
||||
//// }
|
||||
//// User user = UserManager.getUserInMem(session.getUid());
|
||||
//// if(user == null){
|
||||
//// LOGGER.info("the uid={},not in mem",session.getUid());
|
||||
//// return;
|
||||
//// }
|
||||
//// KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,1);
|
||||
//// KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
|
||||
//// LOGGER.info("player={} offLine ...",user.getId());
|
||||
//// OnlineUserManager.userOffline(session.getUid());
|
||||
//// if (session.getCtx() != null) {
|
||||
//// GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
||||
//// }
|
||||
////
|
||||
//// GameMessageHandler.currentSessions.remove(session.getUid());
|
||||
//// processUserOfflineData(user,session);
|
||||
////
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// private void processUserOfflineData(User user,ISession session){
|
||||
//// try {
|
||||
//// GuildLogic.updateMyPos(user);
|
||||
//// if(session.getFiveReady()==1){
|
||||
//// PlayerManager playerInfoManager = user.getPlayerInfoManager();
|
||||
//// playerInfoManager.setOffLineTime(TimeUtils.now());
|
||||
//// long onlineTime = playerInfoManager.getOffLineTime() - session.getLoginTime();
|
||||
//// playerInfoManager.addOnlineTime(onlineTime);
|
||||
//// //更新在线时长
|
||||
//// ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
|
||||
//// MongoUtil.getInstence().lastUpdate();
|
||||
//// session.setFiveReady(0);
|
||||
//// }
|
||||
//// backUpMsgToRedis(session);
|
||||
//// } catch (Exception e) {
|
||||
//// e.printStackTrace();
|
||||
//// } finally {
|
||||
//// //保证数据的保存
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// private void backUpMsgToRedis(ISession session){
|
||||
//// ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
//// LOGGER.info("the uid={} offline.the indication size={}",session.getUid(),indexToIndication.size());
|
||||
//// if(!indexToIndication.isEmpty() ){
|
||||
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
|
||||
//// RedisUtil.getInstence().set(key,gson.toJson(indexToIndication));
|
||||
//// }
|
||||
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
|
||||
//// RedisUtil.getInstence().set(key,String.valueOf(session.getIndicationIndex()));
|
||||
////
|
||||
//// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
//// RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
|
||||
//// }
|
||||
////
|
||||
////
|
||||
//// public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
|
||||
//// if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
|
||||
//// if (requestTime != 0 && requestTime < GameMessageHandler.currentSessions.get(uid).getUserLoginTime()) {
|
||||
//// LOGGER.info("kickOldUser->uid={},requestTime={},userLoginTime={}",
|
||||
//// uid, requestTime, GameMessageHandler.currentSessions.get(uid).getUserLoginTime());
|
||||
//// return false;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// if (!OnlineUserManager.checkUidOnline(uid)) {
|
||||
//// LOGGER.info("kickOldUser->uid={};isNotOnline", uid);
|
||||
//// return false;
|
||||
//// }
|
||||
//// ISession oldSession = OnlineUserManager.getSessionByUid(uid);
|
||||
//// if (oldSession == null) {
|
||||
//// LOGGER.info("kickOldUser->uid={};oldSessionisNull", uid);
|
||||
//// OnlineUserManager.userOffline(uid);
|
||||
//// return false;
|
||||
//// }
|
||||
//// oldSession.setOfflineType(errorCode);
|
||||
////
|
||||
////// if (oldSession.getCtx() != null && !uToken.equals(oldSession.getToken())) {
|
||||
////// Channel oldChannl = oldSession.getCtx().channel();
|
||||
////// if (errorCode == ErrorCode.LOGIN_IN_OTHER_GAMESERVER) {
|
||||
////// OnlineUserLogics.removeFromOnline(uid);
|
||||
////// //转化为踢人消息,
|
||||
////// // 如果当前设备重新登录或重连,登录的其他服务器
|
||||
////// // 那么当前连接应该已经断开,客户端不会收到该消息,则当前设备不会被踢下线
|
||||
////// //如果用其他设备登录,则当前设备能够收到这条消息,则当前设备被踢下线
|
||||
////// errorCode = ErrorCode.LOGIN_IN_OTHER;
|
||||
////// }
|
||||
////// LOGGER.info("kickOldUser->uid={},errorCode={};sendErrorMessageByChannel!", uid, errorCode);
|
||||
////// sendErrorMessageByChannel(oldChannl, errorCode, errorMsg);
|
||||
////// }
|
||||
////
|
||||
//// offLine(oldSession);
|
||||
////// oldSession.close();
|
||||
//// return true;
|
||||
//// }
|
||||
////
|
||||
//// @Override
|
||||
//// public void readIdel(GameSession gameSession) {
|
||||
//// // TODO
|
||||
//// final ISession session = (ISession) gameSession;
|
||||
//// readIdea(session);
|
||||
//// }
|
||||
////
|
||||
////>>>>>>> 843e4f921d5bc65ced6568bf5fc4b58b2b17cf54
|
||||
public BaseHandler getHandler(int msgNum) {
|
||||
return handlers.get(msgNum);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,10 @@ import com.ljsd.jieling.db.mongo.MongoUtil;
|
|||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.ktbeans.KtEventUtils;
|
||||
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
|
@ -16,6 +18,7 @@ import com.ljsd.jieling.logic.dao.PlayerManager;
|
|||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.logic.store.StoreLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.netty.handler.GameMessageHandler;
|
||||
import com.ljsd.jieling.netty.server.IChannel;
|
||||
|
@ -23,8 +26,11 @@ import com.ljsd.jieling.network.session.ISession;
|
|||
import com.ljsd.jieling.protocol.INetConnet;
|
||||
import com.ljsd.jieling.protocol.INetReceived;
|
||||
import com.ljsd.jieling.protocol.INetWorkHandler;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocol.INetSession;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -33,6 +39,7 @@ import util.StringUtil;
|
|||
import util.TimeUtils;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -78,14 +85,9 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
return;
|
||||
}
|
||||
PacketNetData packetNetData = new PacketNetData((byte[]) obj);
|
||||
if (packetNetData.getMsgId() == 1000) {
|
||||
session.setHeartBreatNums(3);
|
||||
MessageUtil.sendHeartBeat(session);
|
||||
return;
|
||||
}
|
||||
|
||||
//处理心跳
|
||||
if (packetNetData.getMsgId() == 1000) {
|
||||
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.HEART_BEAT_REQUEST_VALUE) {
|
||||
dealHeartBeat(session);
|
||||
return;
|
||||
}
|
||||
|
@ -164,9 +166,6 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
return 0;
|
||||
}
|
||||
serverKick(iSession,"您的账号已经在其他设备上登陆,请确认账号安全!");
|
||||
iSession.setOfflineType(ErrorCode.reloginCode);
|
||||
backUpMsgToRedis(iSession);
|
||||
OnlineUserManager.userOffline(uid);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -216,9 +215,28 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
RedisUtil.getInstence().del(key);
|
||||
LOGGER.info("the uid={} cache repsponse is ={},session={}", session.getUid(), index, session.getChannel());
|
||||
}
|
||||
|
||||
}
|
||||
LOGGER.info("the uid={} reconnect,the maxid={} ", session.getUid(), maxMsgId);
|
||||
MessageUtil.sendHeartBeat(session);
|
||||
User userInMem = UserManager.getUserInMem(session.getUid());
|
||||
if(userInMem!=null){
|
||||
ActivityLogic.getInstance().updateActivityMissionProgress(userInMem, ActivityType.OnlineReward,0);
|
||||
try {
|
||||
StoreLogic.checkStoreRefresh(userInMem,userInMem.getStoreManager().getStoreInfoMap());
|
||||
GlobalDataManaager.checkNeedReFlush(session, userInMem, PlayerInfoProto.FivePlayerUpdateIndication.newBuilder());
|
||||
List<CommonProto.Item> allItemList = ItemUtil.getAllItem(userInMem,false);
|
||||
if(!allItemList.isEmpty()){
|
||||
PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(allItemList).setType(0).build();
|
||||
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
|
||||
}
|
||||
if(userInMem.getMapManager().getEndlessMapInfo().getSeason()!= MapLogic.getEndlessSeason()){
|
||||
MapLogic.getInstance().endLessClear(session);
|
||||
}
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("the uid={} processFlush wrong ,e={}",session.getUid(),e);
|
||||
}
|
||||
}
|
||||
MessageUtil.sendMessageWithoutBack(session, 1, MessageTypeProto.MessageType.RECONNECT_RESPONSE_VALUE, null, true);
|
||||
LOGGER.info("the uid={} process reconnect", session.getUid());
|
||||
}
|
||||
|
@ -256,7 +274,6 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
}
|
||||
} else {
|
||||
iSession.setIndex(index);
|
||||
iSession.setLoginTime(System.currentTimeMillis());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -132,10 +132,6 @@ public class ISession extends NettyGameSession {
|
|||
return loginTime;
|
||||
}
|
||||
|
||||
public void setLoginTime(long loginTime) {
|
||||
this.loginTime = loginTime;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, IndicationMsg> getIndexToIndication() {
|
||||
return indexToIndication;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue