mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
公共方法 关闭连接
This commit is contained in:
@@ -208,14 +208,20 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
|
||||
// close(channelId, pileSn);
|
||||
}
|
||||
|
||||
private void close(ChannelId channelId, String pileSn, ChannelHandlerContext ctx) {
|
||||
log.error("close方法-发生异常,关闭链接,channelId:{}, pileSn:{}", channelId.asShortText(), pileSn);
|
||||
|
||||
// 公共方法 关闭连接
|
||||
private void closeConnection(String pileSn, ChannelHandlerContext ctx) {
|
||||
Channel channel = ctx.channel();
|
||||
ChannelId channelId = channel.id();
|
||||
log.error("close方法-发生异常,关闭链接,channelId:{}, pileSn:{}", channelId.asShortText(), pileSn);
|
||||
if (channel != null && !channel.isActive() && !channel.isOpen() && !channel.isWritable()) {
|
||||
channel.close();
|
||||
// 删除连接
|
||||
CHANNEL_MAP.remove(channelId);
|
||||
}
|
||||
// 删除桩编号和channel的关系
|
||||
if (StringUtils.isNotBlank(pileSn)) {
|
||||
// PileChannelEntity.removeByPileSn(pileSn);
|
||||
PileChannelEntity.removeByPileSn(pileSn);
|
||||
}
|
||||
// 删除连接
|
||||
CHANNEL_MAP.remove(channelId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user