RuneHive-Game
Loading...
Searching...
No Matches
ServerPipelineInitializer.java
Go to the documentation of this file.
1package com.runehive.net;
2
3import com.runehive.Config;
4import com.runehive.net.codec.login.LoginDecoder;
5import com.runehive.net.codec.login.LoginResponseEncoder;
6import com.runehive.net.session.Session;
7import io.netty.channel.ChannelInitializer;
8import io.netty.channel.ChannelPipeline;
9import io.netty.channel.socket.SocketChannel;
10import io.netty.handler.codec.haproxy.HAProxyMessageDecoder;
11import io.netty.handler.timeout.IdleStateHandler;
12
13/**
14 * The {@link ChannelInitializer} implementation that will setup the games networking pipeline.
15 *
16 * @author nshusa
17 */
18public final class ServerPipelineInitializer extends ChannelInitializer<SocketChannel> {
19
20 @Override
21 protected void initChannel(SocketChannel ch) {
22 final ChannelPipeline pipeline = ch.pipeline();
23 ch.attr(Config.SESSION_KEY).setIfAbsent(new Session(ch));
24
25 pipeline.addLast("timeout", new IdleStateHandler(Config.IDLE_TIMEOUT, 0, 0));
26
28 pipeline.addLast("haproxy", new HAProxyMessageDecoder());
29 pipeline.addLast("haproxy-handler", new HAProxyMessageHandler());
30 }
31
32 pipeline.addLast("login-decoder", new LoginDecoder());
33 pipeline.addLast("login-encoder", new LoginResponseEncoder());
34 pipeline.addLast("channel-handler", new ChannelHandler());
35 }
36
37}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final boolean SUPPORT_HAPROXY
Definition Config.java:100
static final int IDLE_TIMEOUT
The number of seconds before a connection becomes idle.
Definition Config.java:76
static final AttributeKey< Session > SESSION_KEY
The session key.
Definition Config.java:90
A SimpleChannelInboundHandler implementation for re-routing channel-events to its bound Session.
The ChannelInitializer implementation that will setup the games networking pipeline.
The class that handles a connection through the login protocol.
Represents a session between a user and the server.
Definition Session.java:14