Skip to content

Commit 23302d0

Browse files
committed
Use ctx.fireChannelRead and reorder packet handler
Replace pipeline.fireChannelRead(...) with ctx.fireChannelRead(...) in PollingTransport and WebSocketTransport so events are propagated from the current handler context (next handler) instead of from the pipeline head. Move PACKET_HANDLER registration in SocketIOChannelInitializer to after the transport handlers (but before the encoder) to ensure correct handler ordering and avoid double-processing. Changes affect SocketIOChannelInitializer.java, PollingTransport.java, and WebSocketTransport.java.
1 parent fddd5d1 commit 23302d0

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

netty-socketio-core/src/main/java/com/socketio4j/socketio/SocketIOChannelInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ protected Object newContinueResponse(HttpMessage start, int maxContentLength,
186186
pipeline.addLast(HTTP_COMPRESSION, new HttpContentCompressor());
187187
}
188188

189-
pipeline.addLast(PACKET_HANDLER, packetHandler);
190-
191189
pipeline.addLast(AUTHORIZE_HANDLER, authorizeHandler);
192190
pipeline.addLast(XHR_POLLING_TRANSPORT, xhrPollingTransport);
193191
if (configuration.isWebsocketCompression()) {
194192
pipeline.addLast(WEB_SOCKET_TRANSPORT_COMPRESSION, new WebSocketServerCompressionHandler());
195193
}
196194
pipeline.addLast(WEB_SOCKET_TRANSPORT, webSocketTransport);
195+
196+
pipeline.addLast(PACKET_HANDLER, packetHandler);
197197

198198
pipeline.addLast(SOCKETIO_ENCODER, encoderHandler);
199199

netty-socketio-core/src/main/java/com/socketio4j/socketio/transport/PollingTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private void onPost(UUID sessionId, ChannelHandlerContext ctx, String origin, By
172172
content = decoder.preprocessJson(jsonIndex, content);
173173
}
174174

175-
ctx.pipeline().fireChannelRead(new PacketsMessage(client, content, Transport.POLLING));
175+
ctx.fireChannelRead(new PacketsMessage(client, content, Transport.POLLING));
176176
}
177177

178178
protected void onGet(UUID sessionId, ChannelHandlerContext ctx, String origin) {

netty-socketio-core/src/main/java/com/socketio4j/socketio/transport/WebSocketTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
9797
// Retain its content since we pass it further down the pipeline.
9898
PacketsMessage packetsMessage = new PacketsMessage(client, frame.content().retain(), Transport.WEBSOCKET);
9999
try {
100-
ctx.pipeline().fireChannelRead(packetsMessage);
100+
ctx.fireChannelRead(packetsMessage);
101101
} finally {
102102
frame.release();
103103
}

0 commit comments

Comments
 (0)