RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.net.ChannelHandler Class Reference

A SimpleChannelInboundHandler implementation for re-routing channel-events to its bound Session. More...

Inheritance diagram for com.runehive.net.ChannelHandler:
Collaboration diagram for com.runehive.net.ChannelHandler:

Public Member Functions

void channelInactive (ChannelHandlerContext ctx)
void exceptionCaught (ChannelHandlerContext ctx, Throwable e)
void userEventTriggered (ChannelHandlerContext ctx, Object evt)

Protected Member Functions

void channelRead0 (ChannelHandlerContext ctx, Object o)

Static Private Attributes

static final Logger logger = LogManager.getLogger(ChannelHandler.class)

Detailed Description

A SimpleChannelInboundHandler implementation for re-routing channel-events to its bound Session.

Author
nshusa

Definition at line 18 of file ChannelHandler.java.

Member Function Documentation

◆ channelInactive()

void com.runehive.net.ChannelHandler.channelInactive ( ChannelHandlerContext ctx)

Definition at line 35 of file ChannelHandler.java.

35 {
36 final Session session = ctx.channel().attr(Config.SESSION_KEY).get();
37 if (session != null) {
38 session.close();
39 }
40 }

References com.runehive.Config.SESSION_KEY.

◆ channelRead0()

void com.runehive.net.ChannelHandler.channelRead0 ( ChannelHandlerContext ctx,
Object o )
protected

Definition at line 23 of file ChannelHandler.java.

23 {
24 try {
25 final Session session = ctx.channel().attr(Config.SESSION_KEY).get();
26 if (session != null) {
27 session.handleClientPacket(o);
28 }
29 } catch (Exception ex) {
30 logger.error("Error reading channel!", ex);
31 }
32 }

References logger, and com.runehive.Config.SESSION_KEY.

◆ exceptionCaught()

void com.runehive.net.ChannelHandler.exceptionCaught ( ChannelHandlerContext ctx,
Throwable e )

Definition at line 53 of file ChannelHandler.java.

53 {
54 if (!Config.IGNORED_EXCEPTIONS.contains(e.getMessage())) {
55 logger.error("Exception caught upstream!", e);
56 }
57
58 final Session session = ctx.channel().attr(Config.SESSION_KEY).get();
59 if (session != null) {
60 session.close();
61 }
62 }

References com.runehive.Config.IGNORED_EXCEPTIONS, logger, and com.runehive.Config.SESSION_KEY.

◆ userEventTriggered()

void com.runehive.net.ChannelHandler.userEventTriggered ( ChannelHandlerContext ctx,
Object evt )

Definition at line 43 of file ChannelHandler.java.

43 {
44 if (evt instanceof IdleStateEvent) {
45 IdleStateEvent event = (IdleStateEvent) evt;
46 if (event.state() == IdleState.READER_IDLE) {
47 ctx.channel().close();
48 }
49 }
50 }

Member Data Documentation

◆ logger

final Logger com.runehive.net.ChannelHandler.logger = LogManager.getLogger(ChannelHandler.class)
staticprivate

Definition at line 20 of file ChannelHandler.java.

Referenced by channelRead0(), and exceptionCaught().


The documentation for this class was generated from the following file: