netty-客户端不进行读超时检测

This commit is contained in:
limqhz
2020-07-12 09:59:56 +08:00
parent 6f08b24538
commit a4ea65e843

View File

@@ -113,16 +113,16 @@ public class ServerHandler extends SimpleChannelInboundHandler<String> {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
// 服务器统计现在有的客户端数量, 客户端这个方法用来发心跳
if (evt instanceof IdleStateEvent){
IdleState state = ((IdleStateEvent) evt).state();
if (state == IdleState.READER_IDLE){
logger.info("IdleStateEvent READER_IDLE 超时");
Integer venueId = ctx.channel().attr(Constant.CHANNEL_PARAM).get().getVenueId();
String deviceName = ctx.channel().attr(Constant.CHANNEL_PARAM).get().getDeviceName();
messageService.Offline(deviceName,venueId);
ctx.channel().close();
}
}
// if (evt instanceof IdleStateEvent){
// IdleState state = ((IdleStateEvent) evt).state();
// if (state == IdleState.READER_IDLE){
// logger.info("IdleStateEvent READER_IDLE 超时");
// Integer venueId = ctx.channel().attr(Constant.CHANNEL_PARAM).get().getVenueId();
// String deviceName = ctx.channel().attr(Constant.CHANNEL_PARAM).get().getDeviceName();
// messageService.Offline(deviceName,venueId);
// ctx.channel().close();
// }
// }
Set<String> conns = messageService.countConnection();
logger.info("count connected device ! the count is " + conns.size() + " and they are + [" + conns.toString() + "]" );
}