Java tutorial
/* * This file is part of SpongeRecording, licensed under the MIT License (MIT). * * Copyright (c) 2015 johni0702 <https://github.com/johni0702> * Copyright (c) contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package com.replaymod.sponge.recording.spongecommon; import io.netty.channel.Channel; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; import org.spongepowered.api.Game; /** * Initialize new incoming channels. */ @ChannelHandler.Sharable public class SpongeChannelInitializer extends ChannelInboundHandlerAdapter { private final Game game; public SpongeChannelInitializer(Game game) { this.game = game; } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { Channel channel = (Channel) msg; SpongeConnection connection = new SpongeConnection(game, channel); channel.pipeline().addLast(new SpongeConnectionEventListener(connection)); super.channelRead(ctx, msg); } }