作者 crossoverJie

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

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