mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2025-01-18 23:46:28 +01:00
Merge branch 'ping-pong-timeout' into 'dev'
added ping/pong timeout handlers See merge request morningstar/Arcturus-Community!320
This commit is contained in:
commit
7cffb391ea
@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming;
|
||||
|
||||
public class Incoming {
|
||||
public static final int PongEvent = 2596;
|
||||
public static final int ChangeNameCheckUsernameEvent = 3950;
|
||||
public static final int ConfirmChangeNameEvent = 2977;
|
||||
public static final int ActivateEffectEvent = 2959;
|
||||
|
@ -22,7 +22,7 @@ import com.eu.habbo.messages.outgoing.habboway.nux.NewUserIdentityComposer;
|
||||
import com.eu.habbo.messages.outgoing.handshake.DebugConsoleComposer;
|
||||
import com.eu.habbo.messages.outgoing.handshake.SecureLoginOKComposer;
|
||||
import com.eu.habbo.messages.outgoing.handshake.SessionRightsComposer;
|
||||
import com.eu.habbo.messages.outgoing.handshake.SomeConnectionComposer;
|
||||
import com.eu.habbo.messages.outgoing.handshake.PingComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryAchievementsComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
|
||||
@ -124,7 +124,7 @@ public class SecureLoginEvent extends MessageHandler {
|
||||
messages.add(new NewUserIdentityComposer(habbo).compose());
|
||||
messages.add(new UserPermissionsComposer(this.client.getHabbo()).compose());
|
||||
messages.add(new SessionRightsComposer().compose());
|
||||
messages.add(new SomeConnectionComposer().compose());
|
||||
messages.add(new PingComposer().compose());
|
||||
messages.add(new DebugConsoleComposer(Emulator.debugging).compose());
|
||||
messages.add(new UserAchievementScoreComposer(this.client.getHabbo()).compose());
|
||||
messages.add(new IsFirstLoginOfDayComposer(true).compose());
|
||||
|
@ -493,7 +493,7 @@ public class Outgoing {
|
||||
|
||||
public final static int SimplePollAnswerComposer = 2589;
|
||||
|
||||
public final static int SomeConnectionComposer = 3928;
|
||||
public final static int PingComposer = 3928;
|
||||
public final static int TradingWaitingConfirmComposer = 2720;
|
||||
public final static int BaseJumpJoinQueueComposer = 2260;
|
||||
public final static int ClubCenterDataComposer = 3277;
|
||||
|
@ -4,10 +4,10 @@ import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.MessageComposer;
|
||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||
|
||||
public class SomeConnectionComposer extends MessageComposer {
|
||||
public class PingComposer extends MessageComposer {
|
||||
@Override
|
||||
protected ServerMessage composeInternal() {
|
||||
this.response.init(Outgoing.SomeConnectionComposer);
|
||||
this.response.init(Outgoing.PingComposer);
|
||||
return this.response;
|
||||
}
|
||||
}
|
@ -7,9 +7,11 @@ import com.eu.habbo.networking.Server;
|
||||
import com.eu.habbo.networking.gameserver.decoders.*;
|
||||
import com.eu.habbo.networking.gameserver.encoders.GameServerMessageEncoder;
|
||||
import com.eu.habbo.networking.gameserver.encoders.GameServerMessageLogger;
|
||||
import com.eu.habbo.networking.gameserver.handlers.IdleTimeoutHandler;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.logging.LoggingHandler;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
|
||||
public class GameServer extends Server {
|
||||
private final PacketManager packetManager;
|
||||
@ -30,6 +32,9 @@ public class GameServer extends Server {
|
||||
public void initChannel(SocketChannel ch) throws Exception {
|
||||
ch.pipeline().addLast("logger", new LoggingHandler());
|
||||
|
||||
ch.pipeline().addLast("idleStateHandler", new IdleStateHandler(60, 30, 0));
|
||||
ch.pipeline().addAfter("idleStateHandler", "idleEventHandler", new IdleTimeoutHandler());
|
||||
|
||||
// Decoders.
|
||||
ch.pipeline().addLast(new GamePolicyDecoder());
|
||||
ch.pipeline().addLast(new GameByteFrameDecoder());
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.eu.habbo.networking.gameserver.handlers;
|
||||
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.messages.outgoing.handshake.PingComposer;
|
||||
import com.eu.habbo.networking.gameserver.GameServerAttributes;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
|
||||
public class IdleTimeoutHandler extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
|
||||
if (evt instanceof IdleStateEvent) {
|
||||
IdleStateEvent e = (IdleStateEvent) evt;
|
||||
if (e.state() == IdleState.READER_IDLE) {
|
||||
ctx.close();
|
||||
} else if (e.state() == IdleState.WRITER_IDLE) {
|
||||
GameClient client = ctx.channel().attr(GameServerAttributes.CLIENT).get();
|
||||
if (client != null) {
|
||||
client.sendResponse(new PingComposer());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.userEventTriggered(ctx, evt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user