mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-12 13:24:36 +01:00
Add a config option for specifying kcp connection timeout
This commit is contained in:
@@ -102,10 +102,15 @@ public class Config {
|
||||
public String name = "Lunar Core";
|
||||
public String description = "A LunarCore server";
|
||||
public int kcpInterval = 40;
|
||||
public Integer kcpTimeout = 30;
|
||||
|
||||
public GameServerConfig(int port) {
|
||||
super(port);
|
||||
}
|
||||
|
||||
public int getKcpTimeout() {
|
||||
return kcpTimeout.intValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@@ -197,4 +202,10 @@ public class Config {
|
||||
public String ifixUrl = null;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
if (this.gameServer.kcpTimeout == null) {
|
||||
this.gameServer.kcpTimeout = 30;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -190,6 +190,8 @@ public class LunarCore {
|
||||
// Sanity check
|
||||
if (LunarCore.getConfig() == null) {
|
||||
LunarCore.config = new Config();
|
||||
} else {
|
||||
LunarCore.getConfig().validate();
|
||||
}
|
||||
|
||||
// Save config
|
||||
|
||||
@@ -152,11 +152,11 @@ public class GameServer extends KcpServer {
|
||||
public void start() {
|
||||
// Setup config and init server
|
||||
ChannelConfig channelConfig = new ChannelConfig();
|
||||
channelConfig.nodelay(true, this.getServerConfig().getKcpInterval(), 2, true);
|
||||
channelConfig.nodelay(true, getServerConfig().getKcpInterval(), 2, true);
|
||||
channelConfig.setMtu(1400);
|
||||
channelConfig.setSndwnd(256);
|
||||
channelConfig.setRcvwnd(256);
|
||||
channelConfig.setTimeoutMillis(30 * 1000); // 30s
|
||||
channelConfig.setTimeoutMillis(getServerConfig().getKcpTimeout() * 1000);
|
||||
channelConfig.setUseConvChannel(true);
|
||||
channelConfig.setAckNoDelay(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user