Merge branch 'master_test_gn' of http://60.1.1.230/backend/jieling_server into master_test_gn
commit
dfc37aef28
|
@ -304,6 +304,7 @@ public class GlobalDataManaager implements IManager {
|
||||||
|
|
||||||
public void getTimeOfControl(ISession session){
|
public void getTimeOfControl(ISession session){
|
||||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_RESPONSE_VALUE,getFunctionOfTimeResponse,true);
|
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_RESPONSE_VALUE,getFunctionOfTimeResponse,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGetFunctionOfTimeResponse(){
|
private void updateGetFunctionOfTimeResponse(){
|
||||||
|
@ -321,6 +322,15 @@ public class GlobalDataManaager implements IManager {
|
||||||
long timeOpenOfThis =seasonOpenLong;
|
long timeOpenOfThis =seasonOpenLong;
|
||||||
long timeCloseOfThis =seasonEndLong;
|
long timeCloseOfThis =seasonEndLong;
|
||||||
if(seasonInterval == 0){
|
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;
|
timeOpenOfThis = systemOpenLong;
|
||||||
timeCloseOfThis = systemEndLong;
|
timeCloseOfThis = systemEndLong;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -44,6 +44,7 @@ public class UserManager {
|
||||||
private static Map<Integer,Long> userMapPutTime = new ConcurrentHashMap<>(); //离线读入
|
private static Map<Integer,Long> userMapPutTime = new ConcurrentHashMap<>(); //离线读入
|
||||||
private static AtomicInteger login_f_num = new AtomicInteger(0);//登陆计数
|
private static AtomicInteger login_f_num = new AtomicInteger(0);//登陆计数
|
||||||
private static final int LOGIN_F_LIMIT = 100;//报警界限
|
private static final int LOGIN_F_LIMIT = 100;//报警界限
|
||||||
|
private static final long LIVE_TIME = 12 * 60 * 60 * 1000L;
|
||||||
|
|
||||||
public static void addUser(User user) {
|
public static void addUser(User user) {
|
||||||
userMap.put(user.getId(), user);
|
userMap.put(user.getId(), user);
|
||||||
|
@ -54,22 +55,25 @@ public class UserManager {
|
||||||
return userMap.containsKey(uid);
|
return userMap.containsKey(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getUserMapSize() {
|
||||||
|
return userMap.keySet().size();
|
||||||
|
}
|
||||||
|
|
||||||
//离线清除逻辑
|
//离线清除逻辑
|
||||||
public static void checkOffline(){
|
public static void checkOffline(){
|
||||||
try {
|
try {
|
||||||
Set<User> collect = userMap.entrySet().stream().filter(integerUserEntry -> !OnlineUserManager.checkUidOnline(integerUserEntry.getKey())).map(Map.Entry::getValue).collect(Collectors.toSet());
|
Set<User> collect = userMap.entrySet().stream().filter(integerUserEntry -> !OnlineUserManager.checkUidOnline(integerUserEntry.getKey())).map(Map.Entry::getValue).collect(Collectors.toSet());
|
||||||
long l = System.currentTimeMillis();
|
if (collect.isEmpty()) {
|
||||||
collect.forEach(integerUserEntry -> {
|
|
||||||
long offLineTime = integerUserEntry.getPlayerInfoManager().getOffLineTime();
|
|
||||||
if(offLineTime<integerUserEntry.getPlayerInfoManager().getOnlineTime()){
|
|
||||||
return;
|
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());
|
userMap.remove(integerUserEntry.getId());
|
||||||
userMapPutTime.remove(integerUserEntry.getId());
|
userMapPutTime.remove(integerUserEntry.getId());
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
LOGGER.error("Exception离线清除逻辑err={}",e.toString());
|
LOGGER.error("Exception离线清除逻辑err={}",e.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
*/
|
*/
|
||||||
public class SessionManager implements INetSession<ISession>, INetReceived<ISession>, INetConnet<ISession>, INetWorkHandler {
|
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);
|
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) {
|
public void OnsessionAdd(ISession gameSession) {
|
||||||
currentSessions.put(gameSession.getId(),gameSession);
|
// currentSessions.put(gameSession.getId(),gameSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void OnsessionRemove(String id) {
|
public void OnsessionRemove(String id) {
|
||||||
currentSessions.remove(id);
|
// currentSessions.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -55,12 +55,11 @@ public class MinuteTask extends Thread {
|
||||||
this.setName("MinuteTask");
|
this.setName("MinuteTask");
|
||||||
}
|
}
|
||||||
|
|
||||||
private int i =0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
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 每分钟逻辑通过监听事件处理 已经迁移活动和热更新
|
//TODO 每分钟逻辑通过监听事件处理 已经迁移活动和热更新
|
||||||
Poster.getPoster().dispatchEvent(new MinuteTaskEvent());
|
Poster.getPoster().dispatchEvent(new MinuteTaskEvent());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue