fix network

back_recharge
wangyuan 2019-09-10 16:10:28 +08:00
parent dfeaf4bae0
commit 135450f507
1 changed files with 9 additions and 31 deletions

View File

@ -274,20 +274,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
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;
}
session.setToken(token);
session.setUserLoginTime(System.currentTimeMillis()/1000);
return true;
}
@ -303,10 +291,13 @@ public class ProtocolsManager implements ProtocolsAbstract {
}
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 &&( packetNetData.getMsgId() != MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE || packetNetData.getMsgId() != MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE)){
if (message==null){
//TODO error
LOGGER.info("the uid={},the msg={} is processing",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
return 1;
@ -346,27 +337,14 @@ public class ProtocolsManager implements ProtocolsAbstract {
LOGGER.info("player offLine ...");
ISession session = (ISession) gameSession;
synchronized (session) {
//输出日志
// PrintStream ps= null;
// try {
// ps = new PrintStream("tmp/game.txt");
// Map<MessageTypeProto.MessageType, String> gameMessageForLogin = ProtocolsManager.gameMessageForLogin;
// for (Map.Entry<MessageTypeProto.MessageType, String> entry :gameMessageForLogin.entrySet()){
// String value = entry.getValue();
// ps.println(value);
// }
// ps.close();
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
OnlineUserManager.userOffline(session.getUid());
User user = UserManager.getUserInMem(session.getUid());
if(user == null){
return;
}
KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,1);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
LOGGER.info("player={} offLine ...",user.getId());
if(session.getOfflineType() == ErrorCode.reloginCode){
return;
}
@ -381,7 +359,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
GameMessageHandler.currentSessions.remove(session.getUid());
try {
OnlineUserManager.userOffline(session.getUid());
PlayerManager playerInfoManager = user.getPlayerInfoManager();
playerInfoManager.setOffLineTime(TimeUtils.now());
long onlineTime = playerInfoManager.getOffLineTime() - playerInfoManager.getLoginTime();