List of usage examples for io.netty.channel ChannelPipeline addLast
ChannelPipeline addLast(EventExecutorGroup group, ChannelHandler... handlers);
From source file:com.flysoloing.learning.network.netty.portunification.PortUnificationServerHandler.java
License:Apache License
private void switchToFactorial(ChannelHandlerContext ctx) { ChannelPipeline p = ctx.pipeline(); p.addLast("decoder", new BigIntegerDecoder()); p.addLast("encoder", new NumberEncoder()); p.addLast("handler", new FactorialServerHandler()); p.remove(this); }
From source file:com.flysoloing.learning.network.netty.spdy.client.SpdyClientInitializer.java
License:Apache License
@Override public void initChannel(SocketChannel ch) { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("ssl", sslCtx.newHandler(ch.alloc())); pipeline.addLast("spdyFrameCodec", new SpdyFrameCodec(SPDY_3_1)); pipeline.addLast("spdyFrameLogger", new SpdyFrameLogger(INFO)); pipeline.addLast("spdySessionHandler", new SpdySessionHandler(SPDY_3_1, false)); pipeline.addLast("spdyHttpEncoder", new SpdyHttpEncoder(SPDY_3_1)); pipeline.addLast("spdyHttpDecoder", new SpdyHttpDecoder(SPDY_3_1, MAX_SPDY_CONTENT_LENGTH)); pipeline.addLast("spdyStreamIdHandler", new SpdyClientStreamIdHandler()); pipeline.addLast("httpHandler", httpResponseHandler); }
From source file:com.friz.audio.AudioServer.java
License:Open Source License
@Override public void initialize() { group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); bootstrap = new ServerBootstrap(); AudioServer s = this; bootstrap.group(group).channel(NioServerSocketChannel.class) //.handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override/*from w w w. j a v a2s . co m*/ protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(HttpServerCodec.class.getName(), new HttpServerCodec()); p.addLast(HttpObjectAggregator.class.getName(), new HttpObjectAggregator(65536)); p.addLast(ChunkedWriteHandler.class.getName(), new ChunkedWriteHandler()); p.addLast(AudioChannelHandler.class.getName(), new AudioChannelHandler(s)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); hub.listen(AudioRequestEvent.class, new AudioRequestEventListener()); service.startAsync(); }
From source file:com.friz.game.GameServer.java
License:Open Source License
@Override public void initialize() { group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); bootstrap = new ServerBootstrap(); GameServer s = this; bootstrap.group(group).channel(NioServerSocketChannel.class) //.handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override/*w ww .j a v a 2 s . c om*/ protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(LoginInitEncoder.class.getName(), new LoginInitEncoder()); p.addLast(LoginInitDecoder.class.getName(), new LoginInitDecoder()); p.addLast(GameChannelHandler.class.getName(), new GameChannelHandler(s)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); }
From source file:com.friz.lobby.LobbyServer.java
License:Open Source License
@Override public void initialize() { group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); bootstrap = new ServerBootstrap(); LobbyServer s = this; bootstrap.group(group).channel(NioServerSocketChannel.class) //.handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override//from ww w . jav a2 s .c om protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(LobbyInitEncoder.class.getName(), new LobbyInitEncoder()); p.addLast(LobbyInitDecoder.class.getName(), new LobbyInitDecoder()); p.addLast(LobbyChannelHandler.class.getName(), new LobbyChannelHandler(s)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); eventHub.listen(LobbyInitRequestEvent.class, new LobbyInitEventListener()); eventHub.listen(SocialInitRequestEvent.class, new SocialInitEventListener()); eventHub.listen(CreationRequestEvent.class, new CreationEventListener()); eventHub.listen(LoginRequestEvent.class, new LoginRequestEventListener()); moduleHub.listen(ClientVersionModule.class, new ClientVersionModuleListener()); moduleHub.listen(ClientTypeModule.class, new ClientTypeModuleListener()); }
From source file:com.friz.login.LoginServer.java
License:Open Source License
@Override public void initialize() { group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); bootstrap = new ServerBootstrap(); LoginServer s = this; bootstrap.group(group).channel(NioServerSocketChannel.class) //.handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override// www .j av a 2 s.c o m protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(IdleStateHandler.class.getName(), new IdleStateHandler(15, 0, 0)); p.addLast(LoginChannelHandler.class.getName(), new LoginChannelHandler(s)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); }
From source file:com.friz.owari.network.client.Client.java
License:Open Source License
@Override public void initialize() throws NoSuchAlgorithmException { bootstrap.group(group).channel(NioSocketChannel.class).handler(new ChannelInitializer<NioSocketChannel>() { @Override//from w w w . ja va 2 s . c o m protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(HandshakeEncoder.class.getName(), new HandshakeEncoder()); pipeline.addLast(HandshakeDecoder.class.getName(), new HandshakeDecoder()); pipeline.addLast(IdleStateHandler.class.getName(), new IdleStateHandler(15, 0, 0)); pipeline.addLast(ClientChannelHandler.class.getName(), new ClientChannelHandler(Client.this)); } }).option(ChannelOption.TCP_NODELAY, true); hub.listen(HandshakeEvent.class, new HandshakeListener()); hub.listen(ExchangeRecieveEvent.class, new ExchangeListener()); hub.listen(PatchInitEvent.class, new PatchInitListener()); hub.listen(PatchEvent.class, new PatchListener()); final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DH"); keyPairGenerator.initialize(1024); final KeyPair keyPair = keyPairGenerator.generateKeyPair(); privateKey = keyPair.getPrivate(); publicKey = keyPair.getPublic(); }
From source file:com.friz.owari.network.server.Server.java
License:Open Source License
@Override public void initialize() throws NoSuchAlgorithmException { bootstrap = new ServerBootstrap(); bootstrap.group(group).channel(NioServerSocketChannel.class).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override/* w ww. ja v a2 s. c o m*/ protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast(HandshakeDecoder.class.getName(), new HandshakeDecoder()); pipeline.addLast(HandshakeEncoder.class.getName(), new HandshakeEncoder()); pipeline.addLast(IdleStateHandler.class.getName(), new IdleStateHandler(15, 0, 0)); pipeline.addLast(ServerChannelHandler.class.getName(), new ServerChannelHandler(Server.this)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); hub.listen(HandshakeEvent.class, new HandshakeListener()); hub.listen(ExchangeRecieveEvent.class, new ExchangeListener()); final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DH"); keyPairGenerator.initialize(1024); final KeyPair keyPair = keyPairGenerator.generateKeyPair(); privateKey = keyPair.getPrivate(); publicKey = keyPair.getPublic(); }
From source file:com.friz.update.UpdateServer.java
License:Open Source License
@Override public void initialize() { group = new NioEventLoopGroup(Runtime.getRuntime().availableProcessors()); bootstrap = new ServerBootstrap(); UpdateServer s = this; bootstrap.group(group).channel(NioServerSocketChannel.class) //.handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<NioSocketChannel>() { @Override/* www .ja v a 2s . c o m*/ protected void initChannel(NioSocketChannel ch) throws Exception { ChannelPipeline p = ch.pipeline(); p.addLast(UpdateInitEncoder.class.getName(), new UpdateInitEncoder()); p.addLast(UpdateInitDecoder.class.getName(), new UpdateInitDecoder()); p.addLast(IdleStateHandler.class.getName(), new IdleStateHandler(15, 0, 0)); p.addLast(UpdateChannelHandler.class.getName(), new UpdateChannelHandler(s)); } }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.TCP_NODELAY, true); hub.listen(UpdateRequestEvent.class, new UpdateRequestEventListener()); hub.listen(XorRequestEvent.class, new XorRequestEventListener()); hub.listen(FileRequestEvent.class, new FileRequestEventListener()); service.startAsync(); }
From source file:com.fruit.core.socket.FruitServerPipelineFactory.java
License:Apache License
@Override public void initChannel(SocketChannel ch) throws Exception { ChannelPipeline pipeline = ch.pipeline(); pipeline.addLast("frameDecoder", new ProtobufVarint32FrameDecoder()); pipeline.addLast("protobufDecoder", new ProtobufDecoder(FruitMessage.FruitMessageProto.getDefaultInstance())); pipeline.addLast("frameEncoder", new ProtobufVarint32LengthFieldPrepender()); pipeline.addLast("protobufEncoder", new ProtobufEncoder()); pipeline.addLast("handler", new FruitHandler()); }