作者 crossoverJie

:sparkles: Introducing new features.完善

... ... @@ -44,6 +44,8 @@ public class CIMClientHandle extends SimpleChannelInboundHandler<CIMResponseProt
if (evt instanceof IdleStateEvent){
IdleStateEvent idleStateEvent = (IdleStateEvent) evt ;
LOGGER.info("定时检测服务端是否存活");
if (idleStateEvent.state() == IdleState.WRITER_IDLE){
CIMRequestProto.CIMReqProtocol heartBeat = SpringBeanFactory.getBean("heartBeat",
CIMRequestProto.CIMReqProtocol.class);
... ...
... ... @@ -24,7 +24,7 @@ public class CIMClientHandleInitializer extends ChannelInitializer<Channel> {
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline()
//30 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中
//10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中
.addLast(new IdleStateHandler(0, 10, 0))
//心跳解码
... ...
... ... @@ -61,7 +61,7 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto
IdleStateEvent idleStateEvent = (IdleStateEvent) evt;
if (idleStateEvent.state() == IdleState.READER_IDLE) {
LOGGER.info("定时检测服务端是否存活");
LOGGER.info("定时检测客户端端是否存活");
HeartBeatHandler heartBeatHandler = SpringBeanFactory.getBean(ServerHeartBeatHandlerImpl.class) ;
heartBeatHandler.process(ctx) ;
... ... @@ -119,7 +119,6 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto
@Override
protected void channelRead0(ChannelHandlerContext ctx, CIMRequestProto.CIMReqProtocol msg) throws Exception {
LOGGER.info("收到msg={}", msg.toString());
Thread thread = Thread.currentThread();
if (msg.getType() == Constants.CommandType.LOGIN) {
//保存客户端与 Channel 之间的关系
... ...
... ... @@ -25,7 +25,7 @@ public class CIMServerInitializer extends ChannelInitializer<Channel> {
protected void initChannel(Channel ch) throws Exception {
ch.pipeline()
//30 秒没有向客户端发送消息就发生心跳
//11 秒没有向客户端发送消息就发生心跳
.addLast(new IdleStateHandler(11, 0, 0))
// google Protobuf 编解码
.addLast(new ProtobufVarint32FrameDecoder())
... ...