나는 netty를 사용 해본 적이 없어서 ChannelPipeline의 문서에 대해 질문이 있습니다. 여기가 정확히에 관한 것입니다 : 내가 꽤 MyBusinessLogicHandler
클래스를 이해하지 못하는비즈니스 로직에 netty 사용하기
static final EventExecutorGroup group = new DefaultEventExecutorGroup(16);
...
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("decoder", new MyProtocolDecoder());
pipeline.addLast("encoder", new MyProtocolEncoder());
// Tell the pipeline to run MyBusinessLogicHandler's event handler methods
// in a different thread than an I/O thread so that the I/O thread is not blocked by
// a time-consuming task.
// If your business logic is fully asynchronous or finished very quickly, you don't
// need to specify a group.
pipeline.addLast(group, "handler", new MyBusinessLogicHandler());
. DuplexChannelHandler
또는 다른 것을 구현해야합니까?
public class Packet{}
가 좀 Packet
생산 MyBusinessLogicHandler
에 제공, Packet
에 일부 바이트 시퀀스를 디코딩 할 : 예를 들어, 내 특정 경우에 나는 다음과 같은 클래스가 있습니다. 바이트 스트림으로 다시 인코딩하여 클라이언트로 다시 보냅니다. 나는 이것을 다음과 같이보고 있습니다 :
public class MyBusinessLogicHandler extends SimpleChannelInboundHandler<MyModel>{
public void channelRead0(ChannelHandlerContext ctx, Packet msg){
Packet rslt = null;
//Do some complicated business logic
ctx.write(rslt);
}
}
netty에서 일하는 것이 일반적인 방법인지 잘 모르겠습니다. 제발 좀 더 명확하게 해줄 수 있니?
알았습니다! 감사. –