Merge branch 'master_test_gn' of http://60.1.1.230/backend/jieling_server into master_test_gn

back_recharge
yuanshuai 2021-11-04 14:02:06 +08:00
commit dfc37aef28
4 changed files with 27 additions and 14 deletions

View File

@ -304,6 +304,7 @@ public class GlobalDataManaager implements IManager {
public void getTimeOfControl(ISession session){
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_RESPONSE_VALUE,getFunctionOfTimeResponse,true);
}
private void updateGetFunctionOfTimeResponse(){
@ -321,6 +322,15 @@ public class GlobalDataManaager implements IManager {
long timeOpenOfThis =seasonOpenLong;
long timeCloseOfThis =seasonEndLong;
if(seasonInterval == 0){
int[]limitDay = sGlobalSystemConfig.getIfOpen();
if(limitDay != null && limitDay.length>0){
if( limitDay[0] == 2 ){
long day = TimeUtils.getGapDaysByTwoTime(GameApplication.serverConfig.getOpenTime(),TimeUtils.getTimeStamp2(TimeUtils.now()))+1;
if(day < limitDay[1]){
continue;
}
}
}
timeOpenOfThis = systemOpenLong;
timeCloseOfThis = systemEndLong;
}else{

View File

@ -44,6 +44,7 @@ public class UserManager {
private static Map<Integer,Long> userMapPutTime = new ConcurrentHashMap<>(); //离线读入
private static AtomicInteger login_f_num = new AtomicInteger(0);//登陆计数
private static final int LOGIN_F_LIMIT = 100;//报警界限
private static final long LIVE_TIME = 12 * 60 * 60 * 1000L;
public static void addUser(User user) {
userMap.put(user.getId(), user);
@ -54,22 +55,25 @@ public class UserManager {
return userMap.containsKey(uid);
}
public static int getUserMapSize() {
return userMap.keySet().size();
}
//离线清除逻辑
public static void checkOffline(){
try {
Set<User> collect = userMap.entrySet().stream().filter(integerUserEntry -> !OnlineUserManager.checkUidOnline(integerUserEntry.getKey())).map(Map.Entry::getValue).collect(Collectors.toSet());
long l = System.currentTimeMillis();
collect.forEach(integerUserEntry -> {
long offLineTime = integerUserEntry.getPlayerInfoManager().getOffLineTime();
if(offLineTime<integerUserEntry.getPlayerInfoManager().getOnlineTime()){
if (collect.isEmpty()) {
return;
}
if(l-offLineTime>12*60*60*1000&& userMapPutTime.getOrDefault(integerUserEntry.getId(),0L)>12*60*60*1000){
long now = System.currentTimeMillis();
for (User integerUserEntry : collect) {
Long addTime = userMapPutTime.getOrDefault(integerUserEntry.getId(), LIVE_TIME);
if (now - addTime >= LIVE_TIME) {
userMap.remove(integerUserEntry.getId());
userMapPutTime.remove(integerUserEntry.getId());
}
});
}
}catch (Exception e){
LOGGER.error("Exception离线清除逻辑err={}",e.toString());
}

View File

@ -63,7 +63,7 @@ import java.util.concurrent.TimeUnit;
*/
public class SessionManager implements INetSession<ISession>, INetReceived<ISession>, INetConnet<ISession>, INetWorkHandler {
private Map<String, ISession> currentSessions = new ConcurrentHashMap<>();
// private Map<String, ISession> currentSessions = new ConcurrentHashMap<>();
private static final Logger LOGGER = LoggerFactory.getLogger(SessionManager.class);
@ -74,12 +74,12 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
}
public void OnsessionAdd(ISession gameSession) {
currentSessions.put(gameSession.getId(),gameSession);
// currentSessions.put(gameSession.getId(),gameSession);
}
@Override
public void OnsessionRemove(String id) {
currentSessions.remove(id);
// currentSessions.remove(id);
}
@Override

View File

@ -55,12 +55,11 @@ public class MinuteTask extends Thread {
this.setName("MinuteTask");
}
private int i =0;
@Override
public void run() {
try {
LOGGER.info("MinuteTask start... online use num::{} memory count={}", OnlineUserManager.sessionMap.entrySet().size());
LOGGER.info("MinuteTask start... online use num::{} memory user count={}",
OnlineUserManager.sessionMap.entrySet().size(), UserManager.getUserMapSize());
//TODO 每分钟逻辑通过监听事件处理 已经迁移活动和热更新
Poster.getPoster().dispatchEvent(new MinuteTaskEvent());