作者 crossoverJie

:sparkles: Introducing new features.服务端心跳检测2

@@ -60,12 +60,12 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto @@ -60,12 +60,12 @@ public class CIMServerHandle extends SimpleChannelInboundHandler<CIMRequestProto
60 CIMUserInfo userInfo = SessionSocketHolder.getUserId((NioSocketChannel) future.channel()); 60 CIMUserInfo userInfo = SessionSocketHolder.getUserId((NioSocketChannel) future.channel());
61 if (!future.isSuccess()) { 61 if (!future.isSuccess()) {
62 62
63 - LOGGER.info("向客户端{}下发心跳成功",userInfo.getUserName()); 63 + LOGGER.info("向客户端{}下发心跳失败",userInfo.getUserName());
64 64
65 userOffLine(userInfo, (NioSocketChannel) future.channel()); 65 userOffLine(userInfo, (NioSocketChannel) future.channel());
66 future.channel().close(); 66 future.channel().close();
67 }else { 67 }else {
68 - LOGGER.info("向客户端{}下发心跳失败",userInfo.getUserName()); 68 + LOGGER.info("向客户端{}下发心跳成功",userInfo.getUserName());
69 } 69 }
70 } 70 }
71 }); 71 });
@@ -26,7 +26,7 @@ public class CIMServerInitializer extends ChannelInitializer<Channel> { @@ -26,7 +26,7 @@ public class CIMServerInitializer extends ChannelInitializer<Channel> {
26 26
27 ch.pipeline() 27 ch.pipeline()
28 //45 秒没有向客户端发送消息就发生心跳 28 //45 秒没有向客户端发送消息就发生心跳
29 - .addLast(new IdleStateHandler(45, 0, 0)) 29 + .addLast(new IdleStateHandler(30, 0, 0))
30 // google Protobuf 编解码 30 // google Protobuf 编解码
31 .addLast(new ProtobufVarint32FrameDecoder()) 31 .addLast(new ProtobufVarint32FrameDecoder())
32 .addLast(new ProtobufDecoder(CIMRequestProto.CIMReqProtocol.getDefaultInstance())) 32 .addLast(new ProtobufDecoder(CIMRequestProto.CIMReqProtocol.getDefaultInstance()))