Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
b41d7217ca
|
@ -4,18 +4,34 @@ import com.ljsd.jieling.exception.ErrorCode;
|
|||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Description: 进服前检查
|
||||
* Description: 检查
|
||||
* Author: zsx
|
||||
* CreateDate: 2019/11/5 14:42
|
||||
*/
|
||||
public class Blocker {
|
||||
|
||||
public static final AtomicInteger maxAllowedOnlineAccountCount = new AtomicInteger(5000);
|
||||
private static ConcurrentSet<Integer> forbidLogin = new ConcurrentSet<>();
|
||||
|
||||
public static boolean checkForbidUser(ISession iSession){
|
||||
if(forbidLogin.size()<1){
|
||||
return false;
|
||||
}
|
||||
if(iSession!=null) {
|
||||
if(forbidLogin.contains(iSession.getUid())){
|
||||
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode, "您已被踢下线!");
|
||||
iSession.setOfflineType(ErrorCode.reloginCode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkFlow(ISession iSession){
|
||||
if(iSession!=null) {
|
||||
|
@ -28,6 +44,12 @@ public class Blocker {
|
|||
return true;
|
||||
}
|
||||
|
||||
static Set<Integer> getForbidLogin() {
|
||||
return forbidLogin;
|
||||
}
|
||||
|
||||
|
||||
static void setForbidLogin(Set<Integer> forbidLogin) {
|
||||
Blocker.forbidLogin.clear();
|
||||
Blocker.forbidLogin.addAll(forbidLogin);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
public static Map<MessageTypeProto.MessageType, String> gameMessageForLogin = new ConcurrentHashMap<>();
|
||||
private Map<Integer, BaseHandler> handlers = new HashMap<>();
|
||||
private static ClassLoader classLoader = GameApplication.class.getClassLoader();
|
||||
private static Set<Integer> forbidLogin = new HashSet<>();
|
||||
public final int HANDLER_THREAD_NUM = 50;
|
||||
public HandlerLogicThread[] handlerThreads = new HandlerLogicThread[HANDLER_THREAD_NUM];
|
||||
|
||||
|
@ -202,7 +201,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
if (checkIndex(session,packetNetData) != 0){
|
||||
return;
|
||||
}
|
||||
boolean b = checkForbidUser(session);
|
||||
boolean b = Blocker.checkForbidUser(session);
|
||||
if(b){
|
||||
return;
|
||||
}
|
||||
|
@ -480,31 +479,19 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
}
|
||||
|
||||
|
||||
public boolean checkForbidUser(ISession iSession){
|
||||
if(forbidLogin.size()<1){
|
||||
return false;
|
||||
}
|
||||
if(iSession!=null) {
|
||||
if(forbidLogin.contains(iSession.getUid())){
|
||||
MessageUtil.sendErrorCode(iSession, ErrorCode.reloginCode, "您已被踢下线!");
|
||||
iSession.setOfflineType(ErrorCode.reloginCode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void minuteCheckForbidUser(){
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String key = RedisKey.getKey(RedisKey.FORBID_LOGIN, "", false);
|
||||
if(!redisUtil.hasKey(key)){
|
||||
forbidLogin.clear();
|
||||
Blocker.getForbidLogin().clear();
|
||||
return;
|
||||
}
|
||||
Map<Integer, Integer> forbidMap = redisUtil.getMapValues(RedisKey.FORBID_LOGIN, "", Integer.class, Integer.class);
|
||||
if(forbidMap==null||forbidMap.size()<1){
|
||||
return;
|
||||
}
|
||||
forbidLogin = forbidMap.keySet();
|
||||
Blocker.setForbidLogin(forbidMap.keySet());
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue