网络模块优化
parent
ff0279bddc
commit
f1dc0fcb4c
|
@ -67,53 +67,6 @@ public class GameApplication {
|
|||
CoreSettings coreSettings = ConfigurableApplicationContextManager.getBean(CoreSettings.class);
|
||||
GameApplication.areaId = coreSettings.getArea();
|
||||
LOGGER.info("ServerProperties ->{},coreIp=>{}", serverProperties.toString());
|
||||
//<<<<<<< HEAD
|
||||
//=======
|
||||
// RedisUtil.getInstence().init(configurableApplicationContext);
|
||||
// MongoUtil.getInstence().init(configurableApplicationContext);
|
||||
// //todo 设置开服时间
|
||||
// setRegisterTime();// might loop
|
||||
// //注册消息处理方法
|
||||
// register(configurableApplicationContext);
|
||||
// ProtocolsManager protocolsManager = ProtocolsManager.getInstance();
|
||||
// protocolsManager.initCheck();
|
||||
// // 追加ProtocolsManager消息处理器 注解和非注解
|
||||
// protocolsManager.initHandler("com.ljsd.jieling.handler",configurableApplicationContext);
|
||||
//// protocolsManager.initContext();
|
||||
//
|
||||
// //http线程池初始化
|
||||
// // HttpPool.init();
|
||||
// GuilidManager.init();
|
||||
//
|
||||
// STableManager.initialize("config");
|
||||
// //mongo异步数据处理线程
|
||||
// MongoDataHandlerTask.init(configurableApplicationContext);
|
||||
// //初始化邮件
|
||||
// MailingSystemManager.init(configurableApplicationContext);
|
||||
// ThreadManager threadManager = ThreadManager.getInstance();
|
||||
// threadManager.init(configurableApplicationContext);
|
||||
// MapLogic.getInstance().init(configurableApplicationContext);
|
||||
// MongoKeys.initmongoKey();
|
||||
// SensitivewordFilter.init();
|
||||
// HttpPool.init();
|
||||
//
|
||||
// // 加载lua文件
|
||||
// CheckFight.getInstance().init("luafight/BattleMain.lua");
|
||||
//
|
||||
// final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
|
||||
// NettyProperties properties = netServerConfig.getNettyProperties();
|
||||
//
|
||||
// KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum());
|
||||
// ActivityLogic.getInstance().checkActiviyStatus();
|
||||
// //初始化cdk
|
||||
// CoreLogic.getInstance().checkCoreCdk();
|
||||
// ThriftPoolUtils.getInstance().initContext(configurableApplicationContext);
|
||||
// GlobalDataManaager.getInstance().whenServerStart(configurableApplicationContext);
|
||||
// URL resource = HeroLogic.class.getClassLoader().getResource("mingan.txt");
|
||||
// if(resource!=null){
|
||||
// LOGGER.info(resource.getFile());
|
||||
// }
|
||||
//>>>>>>> 843e4f921d5bc65ced6568bf5fc4b58b2b17cf54
|
||||
|
||||
GameLogicService.getInstance().init();
|
||||
//设置开服时间
|
||||
|
@ -141,7 +94,6 @@ public class GameApplication {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
long serverOenTime = TimeUtils.getAppointTime(0);
|
||||
String format = simpleDateFormat.format(serverOenTime);
|
||||
|
@ -160,9 +112,7 @@ public class GameApplication {
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static void close() throws Exception{
|
||||
|
||||
start = false;
|
||||
NetManager.getInstance().exit();
|
||||
ConfigurableApplicationContextManager.getInstance().exit();
|
||||
|
|
|
@ -28,6 +28,7 @@ import com.ljsd.jieling.protocol.INetSession;
|
|||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.NetUtils;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
|
@ -213,7 +214,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
Integer index = response.keySet().iterator().next();
|
||||
session.setIndex(index);
|
||||
RedisUtil.getInstence().del(key);
|
||||
LOGGER.info("the uid={} cache repsponse is ={},session={}", session.getUid(), index, session.getCtx().channel());
|
||||
LOGGER.info("the uid={} cache repsponse is ={},session={}", session.getUid(), index, session.getChannel());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -291,11 +292,11 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
|
||||
LOGGER.info("player={} offLine ...",user.getId());
|
||||
OnlineUserManager.userOffline(session.getUid());
|
||||
if (session.getCtx() != null) {
|
||||
GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
||||
}
|
||||
|
||||
OnlineUserManager.sessionMap.remove(session.getUid());
|
||||
// if (session.getCtx() != null) {
|
||||
// GameMessageHandler.allChannels.remove(session.getCtx().channel());
|
||||
// }
|
||||
// OnlineUserManager.sessionMap.remove(session.getUid());
|
||||
processUserOfflineData(user,session);
|
||||
|
||||
}
|
||||
|
@ -309,9 +310,12 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
return;
|
||||
}
|
||||
String remoteAddress = "";
|
||||
if (iSession.getCtx() != null && iSession.getCtx().channel() != null && iSession.getCtx().channel().remoteAddress() != null) {
|
||||
remoteAddress = iSession.getCtx().channel().remoteAddress().toString();
|
||||
if (!iSession.getChannel().isClosed() && iSession.getChannel().isConnected()) {
|
||||
remoteAddress = NetUtils.toAddressString(iSession.getChannel().getRemoteAddress());
|
||||
}
|
||||
// if (iSession.getCtx() != null && iSession.getCtx().channel() != null && iSession.getCtx().channel().remoteAddress() != null) {
|
||||
// remoteAddress = iSession.getCtx().channel().remoteAddress().toString();
|
||||
// }
|
||||
LOGGER.error("readIdea->uid={},iSessionId={},HeartBreatNums={},remoteAddress={};not receieve heart breat",
|
||||
iSession.getUid(), iSession.getId(), iSession.getHeartBreatNums(), remoteAddress);
|
||||
int heartBreatNums = iSession.getHeartBreatNums();
|
||||
|
@ -321,7 +325,7 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
|
|||
iSession.close();
|
||||
return;
|
||||
}
|
||||
ISession oldSession = (ISession) OnlineUserManager.sessionMap.get(iSession.getUid());
|
||||
ISession oldSession = OnlineUserManager.sessionMap.get(iSession.getUid());
|
||||
if (iSession.getId().equals(oldSession.getId())) {
|
||||
kickOldUser(iSession.getUid(), "", 000, "LOSE HEART PACKET!!!!", 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue