|
|
|
package com.crossoverjie.netty.action.client.handle;
|
|
|
|
|
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import com.crossoverjie.netty.action.common.protocol.BaseResponseProto;
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
|
import io.netty.channel.SimpleChannelInboundHandler;
|
|
|
|
import io.netty.util.CharsetUtil;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
...
|
...
|
@@ -14,7 +13,7 @@ import org.slf4j.LoggerFactory; |
|
|
|
* Date: 16/02/2018 18:09
|
|
|
|
* @since JDK 1.8
|
|
|
|
*/
|
|
|
|
public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> {
|
|
|
|
public class EchoClientHandle extends SimpleChannelInboundHandler<BaseResponseProto.ResponseProtocol> {
|
|
|
|
|
|
|
|
private final static Logger LOGGER = LoggerFactory.getLogger(EchoClientHandle.class);
|
|
|
|
|
|
...
|
...
|
@@ -47,11 +46,12 @@ public class EchoClientHandle extends SimpleChannelInboundHandler<ByteBuf> { |
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf in) throws Exception {
|
|
|
|
protected void channelRead0(ChannelHandlerContext channelHandlerContext, BaseResponseProto.ResponseProtocol responseProtocol) throws Exception {
|
|
|
|
|
|
|
|
//从服务端收到消息时被调用
|
|
|
|
LOGGER.info("客户端收到消息={}",in.toString(CharsetUtil.UTF_8)) ;
|
|
|
|
//LOGGER.info("客户端收到消息={}",in.toString(CharsetUtil.UTF_8)) ;
|
|
|
|
|
|
|
|
LOGGER.info("客户端收到消息={}" ,responseProtocol.getResMsg());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
...
|
...
|
|