作者 crossoverJie

:sparkles: Introducing new features.完善

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