|
15 | 15 | */
|
16 | 16 | package com.corundumstudio.socketio.transport;
|
17 | 17 |
|
18 |
| -import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; |
19 |
| - |
20 |
| -import java.io.IOException; |
21 |
| -import java.util.List; |
22 |
| -import java.util.UUID; |
23 |
| - |
24 |
| -import org.slf4j.Logger; |
25 |
| -import org.slf4j.LoggerFactory; |
26 |
| - |
27 | 18 | import com.corundumstudio.socketio.Transport;
|
28 | 19 | import com.corundumstudio.socketio.handler.AuthorizeHandler;
|
29 | 20 | import com.corundumstudio.socketio.handler.ClientHead;
|
|
33 | 24 | import com.corundumstudio.socketio.messages.XHROptionsMessage;
|
34 | 25 | import com.corundumstudio.socketio.messages.XHRPostMessage;
|
35 | 26 | import com.corundumstudio.socketio.protocol.PacketDecoder;
|
36 |
| - |
37 | 27 | import io.netty.buffer.ByteBuf;
|
| 28 | +import io.netty.channel.Channel; |
38 | 29 | import io.netty.channel.ChannelFutureListener;
|
39 | 30 | import io.netty.channel.ChannelHandler.Sharable;
|
40 | 31 | import io.netty.channel.ChannelHandlerContext;
|
41 | 32 | import io.netty.channel.ChannelInboundHandlerAdapter;
|
42 |
| -import io.netty.handler.codec.http.DefaultHttpResponse; |
43 |
| -import io.netty.handler.codec.http.FullHttpRequest; |
44 |
| -import io.netty.handler.codec.http.HttpHeaderNames; |
45 |
| -import io.netty.handler.codec.http.HttpMethod; |
46 |
| -import io.netty.handler.codec.http.HttpResponse; |
47 |
| -import io.netty.handler.codec.http.HttpResponseStatus; |
48 |
| -import io.netty.handler.codec.http.QueryStringDecoder; |
| 33 | +import io.netty.handler.codec.http.*; |
| 34 | +import org.slf4j.Logger; |
| 35 | +import org.slf4j.LoggerFactory; |
| 36 | + |
| 37 | +import java.io.IOException; |
| 38 | +import java.util.List; |
| 39 | +import java.util.UUID; |
| 40 | + |
| 41 | +import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1; |
49 | 42 |
|
50 | 43 | @Sharable
|
51 | 44 | public class PollingTransport extends ChannelInboundHandlerAdapter {
|
@@ -186,4 +179,15 @@ private void sendError(ChannelHandlerContext ctx) {
|
186 | 179 | ctx.channel().writeAndFlush(res).addListener(ChannelFutureListener.CLOSE);
|
187 | 180 | }
|
188 | 181 |
|
| 182 | + @Override |
| 183 | + public void channelInactive(ChannelHandlerContext ctx) throws Exception { |
| 184 | + final Channel channel = ctx.channel(); |
| 185 | + ClientHead client = clientsBox.get(channel); |
| 186 | + if (client != null && client.isTransportChannel(ctx.channel(), Transport.POLLING)) { |
| 187 | + log.debug("channel inactive {}", client.getSessionId()); |
| 188 | + client.releasePollingChannel(channel); |
| 189 | + } |
| 190 | + super.channelInactive(ctx); |
| 191 | + } |
| 192 | + |
189 | 193 | }
|
0 commit comments