控制台gm命令 netty关闭流程修改

back_recharge
zhangshanxue 2019-12-11 15:19:38 +08:00
parent a82d645499
commit ed7545aba3
4 changed files with 42 additions and 16 deletions

View File

@ -85,15 +85,14 @@ public class NettyGameServer extends AbstractServer {
}
});
serverBootstrap.bind(getLocalAddress().getPort()).sync().channel().closeFuture().sync();
// ChannelFuture channelFuture = serverBootstrap.bind(getLocalAddress().getPort());
// this.channel = channelFuture.channel();
// channelFuture.sync();
// channelFuture.channel().closeFuture().sync();
ChannelFuture channelFuture = serverBootstrap.bind(getLocalAddress().getPort()).sync();
this.channel = channelFuture.channel();
//同步关闭改异步回调 优雅关闭netty
this.channel.closeFuture().addListener((ChannelFutureListener) future -> close());
} catch (Exception e) {
throw new ConnectException("close exception", getLocalAddress(), null);
} finally {
close();
// close();
}
}

View File

@ -22,6 +22,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;
@Configuration
@ -57,6 +58,23 @@ public class GameApplication {
setRegisterTime();// might loop
GameLogicService.getInstance().onStart();
NetManager.getInstance().init();
//控制台gm
Scanner sc = new Scanner(System.in);
while(sc.hasNext())
{
try {
String cmd = sc.nextLine();
if(cmd.startsWith("//"))
{
System.out.println("执行命令:" + cmd.substring(2));
String cmd2 = cmd.substring(2);
GmService.exeCmd(cmd2);
}
}catch (Exception e){
System.out.print("gmException"+e);
}
}
}
private static void setRegisterTime() throws Exception {

View File

@ -40,6 +40,12 @@ public class GmService implements RPCRequestGMIFace.Iface {
@Override
public Result idipGm(String reserved, String cmd) throws InvalidOperException, TException {
return exeCmd(cmd);
}
static Result exeCmd(String cmd){
LOGGER.info("gm________________________"+cmd);
Result result = new Result();
result.setResultCode(-1);
@ -68,10 +74,10 @@ public class GmService implements RPCRequestGMIFace.Iface {
sendIds.add(user1.getId());
}
InnerMessageUtil.broadcastWithRandom( user->{
LOGGER.info("hotfix user={}",user.getId());
MongoUtil.getLjsdMongoTemplate().save(user);
}
, sendIds, Math.min(10, 10));
LOGGER.info("hotfix user={}",user.getId());
MongoUtil.getLjsdMongoTemplate().save(user);
}
, sendIds, Math.min(10, 10));
result.setResultCode(1);
return result;
}
@ -90,7 +96,7 @@ public class GmService implements RPCRequestGMIFace.Iface {
if (obj instanceof GmRoleAbstract) {
//todo
//todo
Map<Integer, String> rechargeInfoMap = new HashMap<>();
if(cmd.contains("recharge")){
File file = new File("../conf/BuyGoodsLogic.log");
@ -174,8 +180,8 @@ public class GmService implements RPCRequestGMIFace.Iface {
}
InnerMessageUtil.broadcastWithRandom( user->{
((GmRoleAbstract) obj).setUser(user);
obj.exec(parameters2);
((GmRoleAbstract) obj).setUser(user);
obj.exec(parameters2);
}, sendIds, Math.min(randomTime, 120));
} else {
LOGGER.info("gm________________________start"+cmd);
@ -190,7 +196,6 @@ public class GmService implements RPCRequestGMIFace.Iface {
}
result.setResultCode(0);
return result;
}
}

View File

@ -92,7 +92,11 @@ public class SessionManager implements INetSession<ISession>, INetReceived<ISess
return;
}
LOGGER.info("request={} commond ={}: ", packetNetData.getUserId(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
if(packetNetData.getMsgId()!=MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE)
{
//聊天请求太多了 过滤掉
LOGGER.info("request={} commond ={}: ", packetNetData.getUserId(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
}
if (packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE ||
packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE) {
if (!onLoginORReLoginRequest(session, packetNetData)) {