22
33import io .netty .channel .Channel ;
44import io .netty .channel .ChannelHandlerContext ;
5- import io .netty .channel .ChannelInboundHandlerAdapter ;
65import io .netty .channel .SimpleChannelInboundHandler ;
76import io .netty .handler .codec .http .FullHttpResponse ;
87import io .netty .handler .timeout .ReadTimeoutException ;
1615/**
1716 * @author: wangqi
1817 * @description:
19- * @date: Created in 2018-11-26 20:59
18+ * @date: Created in 2018-11-28 08:37
2019 */
21- public class HttpHandler extends ChannelInboundHandlerAdapter {
20+ public class HttpHandler extends SimpleChannelInboundHandler < FullHttpResponse > {
2221 private Logger logger = LoggerFactory .getLogger (HttpHandler .class );
2322
24- @ Override
25- public void channelActive (ChannelHandlerContext ctx ) throws Exception {
26- System .out .println ("channelActive" );
27- super .channelActive (ctx );
23+ public HttpHandler () {
24+ super (false );
2825 }
2926
3027 @ Override
31- public void channelRead (ChannelHandlerContext ctx , Object msg ) throws Exception {
32- FullHttpResponse response = (FullHttpResponse ) msg ;
28+ protected void channelRead0 (ChannelHandlerContext ctx , FullHttpResponse response ) throws Exception {
3329 logger .debug ("handler hashCode: {}" , this .hashCode ());
3430 logger .debug ("clientChannelId: {}" , ctx .channel ().id ());
3531 Channel serverChannel = ctx .channel ().attr (Attributes .SERVER_CHANNEL ).get ();
@@ -40,6 +36,12 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
4036 GatewayRunner .getInstance ().postRoutAction (serverChannel );
4137 }
4238
39+ @ Override
40+ public void channelActive (ChannelHandlerContext ctx ) throws Exception {
41+ System .out .println ("channelActive" );
42+ super .channelActive (ctx );
43+ }
44+
4345 @ Override
4446 public void exceptionCaught (ChannelHandlerContext ctx , Throwable cause ) throws Exception {
4547 Channel serverChannel = ctx .channel ().attr (Attributes .SERVER_CHANNEL ).get ();
0 commit comments