Commit 3d2582d2 by giaogiao

添加close ChannelFuture

parent 888fcd4d
...@@ -4,6 +4,8 @@ import cn.hutool.core.thread.ThreadFactoryBuilder; ...@@ -4,6 +4,8 @@ import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.wecloud.im.ws.model.WsConstants; import com.wecloud.im.ws.model.WsConstants;
import com.wecloud.im.ws.receive.ReadWsData; import com.wecloud.im.ws.receive.ReadWsData;
import com.wecloud.im.ws.service.MangerChannelService; import com.wecloud.im.ws.service.MangerChannelService;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler; import io.netty.channel.SimpleChannelInboundHandler;
...@@ -118,9 +120,15 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram ...@@ -118,9 +120,15 @@ public class WsReadHandler extends SimpleChannelInboundHandler<TextWebSocketFram
@Override @Override
public void handlerRemoved(ChannelHandlerContext ctx) { public void handlerRemoved(ChannelHandlerContext ctx) {
String userIdByChannel = mangerChannelService.getInfoByChannel(ctx); String userIdByChannel = mangerChannelService.getInfoByChannel(ctx);
log.info("uid:" + userIdByChannel + "," + "handlerRemoved" + ",channelId:" + ctx.channel().id().asShortText()); String asLongText = ctx.channel().id().asLongText();
log.info("uid:" + userIdByChannel + "," + "handlerRemoved-begin" + ",channelId:" + asLongText);
// 关掉连接 // 关掉连接
ctx.close(); ChannelFuture close = ctx.close();
close.addListener(
//执行后回调的方法
(ChannelFutureListener) channelFuture1 -> {
log.info("uid:" + userIdByChannel + "," + "handlerRemoved-success" + ",channelId:" + asLongText);
});
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment