token验证

back_recharge
zhangshanxue 2019-09-09 15:04:39 +08:00
parent 1b61c88da1
commit 5ff27b049c
1 changed files with 19 additions and 19 deletions

View File

@ -165,7 +165,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
//处理多设备重登
dealRepeatLogin(session.getUid());
//刷新token
// refreshToken(session);
refreshToken(session);
//踢下线
//在线列表加入session
OnlineUserManager.userOnline(session.getUid(),session);
@ -180,10 +180,10 @@ public class ProtocolsManager implements ProtocolsAbstract {
return;
}
//检查token
if (checkToken(session,packetNetData) != 0 ){
MessageUtil.sendErrorCode(session,0,"您的账号token不正确请退出游戏重新登陆!");
return;
}
// if (checkToken(session,packetNetData) != 0 ){
// MessageUtil.sendErrorCode(session,0,"您的账号token不正确请退出游戏重新登陆!");
// return;
// }
if( packetNetData.getMsgId()== MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
processReconnect(session);
@ -274,20 +274,20 @@ 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;
}
// 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;
}