fix reconnect
parent
e925b88ffd
commit
678c06c998
|
@ -297,6 +297,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
ISession iSession = OnlineUserManager.getSessionByUid(uid);
|
||||
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode,"您的账号已经在其他设备上登陆,请确认账号安全!");
|
||||
iSession.setOfflineType(ErrorCode.reloginCode);
|
||||
backUpMsgToRedis(iSession);
|
||||
offLine(iSession);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -311,7 +313,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
byte[] message = iSession.getCacheMessage(index);
|
||||
if (message==null){
|
||||
//TODO error
|
||||
LOGGER.info("the uid={},the msg={} is processing",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
|
||||
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()));
|
||||
|
@ -349,7 +351,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
LOGGER.info("player offLine ...");
|
||||
ISession session = (ISession) gameSession;
|
||||
synchronized (session) {
|
||||
OnlineUserManager.userOffline(session.getUid());
|
||||
User user = UserManager.getUserInMem(session.getUid());
|
||||
if(user == null){
|
||||
return;
|
||||
|
@ -360,6 +361,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
if(session.getOfflineType() == ErrorCode.reloginCode){
|
||||
return;
|
||||
}
|
||||
OnlineUserManager.userOffline(session.getUid());
|
||||
if (session.getCtx() != null) {
|
||||
GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
||||
}
|
||||
|
@ -380,14 +382,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
|
||||
GuildLogic.updateMyPos(user);
|
||||
MongoUtil.getInstence().lastUpdate();
|
||||
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
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.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
|
||||
backUpMsgToRedis(session);
|
||||
// 下线处理的逻辑需要添加在这里
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -397,6 +392,18 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
}
|
||||
}
|
||||
|
||||
private void backUpMsgToRedis(ISession session){
|
||||
ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
|
||||
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.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
|
||||
LOGGER.info("the uid={},the offlineIndex={},",session.getUid(),session.getIndexToMessage().keySet().iterator().next());
|
||||
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)) {
|
||||
|
|
Loading…
Reference in New Issue