@@ -0,0 +1,2166 @@
+package io.elssa.nn;%0A%0Aimport java.net.InetSocketAddress;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aimport io.netty.channel.ChannelHandlerContext;%0Aimport io.netty.channel.ChannelInboundHandlerAdapter;%0A%0Apublic class ServerInboundHandler extends ChannelInboundHandlerAdapter %7B%0A%0A    final Logger logger = LoggerFactory.getLogger(ServerInboundHandler.class);%0A%0A    private List%3CMessageListener%3E listeners = new ArrayList%3C%3E();%0A%0A    public void addListener(MessageListener listener) %7B%0A        listeners.add(listener);%0A    %7D%0A%0A    public void removeListener(MessageListener listener) %7B%0A        listeners.remove(listener);%0A    %7D%0A%0A    @Override%0A    public void channelActive(ChannelHandlerContext ctx) %7B%0A        InetSocketAddress addr%0A            = (InetSocketAddress) ctx.channel().remoteAddress();%0A        NetworkEndpoint endpoint = new NetworkEndpoint(%0A                addr.getHostName(), addr.getPort());%0A        logger.info(%22Accepted connection: %7B%7D%22, endpoint.toString());%0A%0A        for (MessageListener listener : listeners) %7B%0A            listener.onConnect(endpoint);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void channelInactive(ChannelHandlerContext ctx) %7B%0A        InetSocketAddress addr%0A            = (InetSocketAddress) ctx.channel().remoteAddress();%0A        NetworkEndpoint endpoint = new NetworkEndpoint(%0A                addr.getHostName(), addr.getPort());%0A        logger.info(%22Terminating connection: %7B%7D%22, endpoint);%0A%0A        for (MessageListener listener : listeners) %7B%0A            listener.onDisconnect(endpoint);%0A        %7D%0A    %7D%0A%0A    /**%0A     * Dispatches a message to all listening consumers.%0A     *%0A     * @param message %7B@link ElssaMessage%7D to dispatch.%0A     */%0A    @Override%0A    public void channelRead(ChannelHandlerContext ctx, Object msg) %7B%0A        if (msg instanceof ElssaMessage) %7B%0A            for (MessageListener listener : listeners) %7B%0A                listener.onMessage((ElssaMessage) msg);%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) %7B%0A        logger.info(%22Inbound channel exception%22, cause);%0A    %7D%0A%7D%0A

Move server processing logic to ChannelHandler