🆙 Added disconnects through Cloudflare fix

Thanks to Cyb3rBlu3
This commit is contained in:
DuckieTM
2025-06-01 13:47:42 +02:00
parent 6f5626341b
commit 7620fda26a
4 changed files with 19 additions and 0 deletions
@@ -140,6 +140,7 @@ public final class Emulator {
Emulator.gameEnvironment.load();
Emulator.gameServer.initializePipeline();
Emulator.gameServer.connect();
Emulator.getGameServer().getGameClientManager().CFKeepAlive();
Emulator.rconServer.initializePipeline();
Emulator.rconServer.connect();
Emulator.badgeImager = new BadgeImager();
@@ -107,6 +107,12 @@ public class GameClient {
}
}
public void sendKeepAlive() {
if (this.channel != null && this.channel.isOpen()) {
this.channel.writeAndFlush(new ServerMessage(-1));
}
}
public void dispose() {
try {
this.channel.close();
@@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.gameclients;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
@@ -162,4 +163,15 @@ public class GameClientManager {
}
}
}
public void CFKeepAlive() {
Emulator.getThreading().run(() -> {
for (GameClient client : this.clients.values()) {
if (client != null && client.getChannel().isActive()) {
client.sendKeepAlive();
}
}
CFKeepAlive();
}, 30000);
}
}