Guest User

Untitled

a guest
Nov 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. static final EventExecutorGroup group = new DefaultEventExecutorGroup(16);
  2. ...
  3.  
  4. ChannelPipeline pipeline = ch.pipeline();
  5.  
  6. pipeline.addLast("decoder", new MyProtocolDecoder());
  7. pipeline.addLast("encoder", new MyProtocolEncoder());
  8.  
  9. // Tell the pipeline to run MyBusinessLogicHandler's event handler methods
  10. // in a different thread than an I/O thread so that the I/O thread is not blocked by
  11. // a time-consuming task.
  12. // If your business logic is fully asynchronous or finished very quickly, you don't
  13. // need to specify a group.
  14. pipeline.addLast(group, "handler", new MyBusinessLogicHandler());
  15.  
  16. public class Packet{}
  17.  
  18. public class MyBusinessLogicHandler extends SimpleChannelInboundHandler<MyModel>{
  19. public void channelRead0(ChannelHandlerContext ctx, Packet msg){
  20. Packet rslt = null;
  21. //Do some complicated business logic
  22. ctx.write(rslt);
  23. }
  24. }
Add Comment
Please, Sign In to add comment