@Override
 public void initChannel(SocketChannel ch) throws Exception {
   ch.pipeline()
       .addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
   ch.pipeline().addLast("decoder", new StringDecoder());
   ch.pipeline().addLast("encoder", new StringEncoder());
   ch.pipeline().addLast(handler.newInstance());
 }
Example #2
0
 public final void initChannel(SocketChannel channel) {
   channel
       .pipeline()
       .addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
   channel.pipeline().addLast("stringDecoder", this.decoder);
   channel.pipeline().addLast("encoder", this.encoder);
   channel.pipeline().addLast("handler", new Handler());
 }
 @Override
 protected void initChannel(SocketChannel soc) throws Exception {
   soc.pipeline()
       .addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
   soc.pipeline().addLast("decoder", new StringDecoder());
   soc.pipeline().addLast("encoder", new StringEncoder());
   soc.pipeline().addLast("handleridle", new IdleStateHandler(10, 10, 0));
   soc.pipeline().addLast("handler", new StringServerPacketHandler());
 }
Example #4
0
  @Override
  public ChannelHandler[] make(SocketChannel _socketChannel) {
    ChannelHandler[] pipe =
        new ChannelHandler[] {
          new DelimiterBasedFrameDecoder(this.maxLength, Delimiters.nulDelimiter()),
          new StringDecoder(Charset.forName(ConstantKey.NETWORK_CHARSET)),
          new StringEncoder(Charset.forName(ConstantKey.NETWORK_CHARSET))
        };

    return pipe;
  }
  @Override
  public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add the text line codec combination first,
    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast("decoder", DECODER);
    pipeline.addLast("encoder", ENCODER);

    // and then business logic.
    pipeline.addLast("handler", CLIENTHANDLER);
  }
  @Override
  public void initChannel(SocketChannel ch) {
    ChannelPipeline pipeline = ch.pipeline();

    // Add the text line codec combination first,
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(DECODER);
    pipeline.addLast(ENCODER);

    // and then business logic.
    pipeline.addLast(CLIENT_HANDLER);
  }
  @Override
  protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // 以("\n")为结尾分割的 解码器
    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));

    // 字符串解码 和 编码
    pipeline.addLast("decoder", new StringDecoder());
    pipeline.addLast("encoder", new StringEncoder());

    // 自己的逻辑Handler
    pipeline.addLast("handler", new HelloServerHandler());
  }
Example #8
0
  @Override
  public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add the text line codec combination first,
    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    // the encoder and decoder are static as these are sharable
    pipeline.addLast("decoder", DECODER);
    pipeline.addLast("encoder", ENCODER);
    nhs.server = new TelnetServer();
    nhs.server.server = nhs;
    // and then business logic.
    pipeline.addLast("handler", nhs.server);
  }
  @Override
  protected void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();
    SSLEngine engine = SecureChatSslContextFactory.getServerContext().createSSLEngine();
    engine.setUseClientMode(false);

    pipeline.addLast("ssl", new SslHandler(engine));

    pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast("decoder", new StringDecoder());
    pipeline.addLast("encoder", new StringEncoder());

    // and then business logic.
    pipeline.addLast("handler", new SecureChatServerHandler());
  }
  @Override
  public void initChannel(SocketChannel ch) throws Exception {
    ChannelPipeline pipeline = ch.pipeline();

    // Add SSL handler first to encrypt and decrypt everything.
    // In this example, we use a bogus certificate in the server side
    // and accept any invalid certificates in the client side.
    // You will need something more complicated to identify both
    // and server in the real world.
    pipeline.addLast(sslCtx.newHandler(ch.alloc()));

    // On top of the SSL handler, add the text line codec.
    pipeline.addLast(new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
    pipeline.addLast(new StringDecoder());
    pipeline.addLast(new StringEncoder());

    // and then business logic.
    pipeline.addLast(new SecureChatServerHandler());
  }