Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import io.netty.channel.ChannelInitializer;
- import io.netty.channel.ChannelPipeline;
- import io.netty.channel.socket.SocketChannel;
- public class ServerAdapterInitializer extends ChannelInitializer<SocketChannel> {
- @Override
- protected void initChannel(SocketChannel channel) throws Exception {
- ChannelPipeline pipeline = channel.pipeline();
- pipeline.addLast("encoder", new Encoder());//Кодирует
- pipeline.addLast("decoder", new Decoder());//Расшифровывает
- pipeline.addLast("handler", new ServerAdapterHandler());// ServerAdapterHandler() будет принимать все пакеты от клиентов.
- }
- }
- import com.sun.xml.internal.ws.api.message.Packet;
- import io.netty.buffer.ByteBuf;
- import io.netty.channel.ChannelHandlerContext;
- import io.netty.handler.codec.MessageToByteEncoder;
- public class Encoder extends MessageToByteEncoder<Packet> {
- @Override
- protected void encode(ChannelHandlerContext channelHandlerContext, Packet packet, ByteBuf byteBuf) throws Exception {
- }
- }
Add Comment
Please, Sign In to add comment