Skip to content

Commit eb7b206

Browse files
committed
Expose ChannelId from ReactorNettyWebSocketSession
Closes gh-26485
1 parent 42061d2 commit eb7b206

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818

1919
import java.util.function.Consumer;
2020

21+
import io.netty.channel.ChannelId;
2122
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
2223
import org.reactivestreams.Publisher;
2324
import reactor.core.publisher.Flux;
2425
import reactor.core.publisher.Mono;
2526
import reactor.netty.Connection;
2627
import reactor.netty.NettyInbound;
2728
import reactor.netty.NettyOutbound;
29+
import reactor.netty.channel.ChannelOperations;
2830
import reactor.netty.http.websocket.WebsocketInbound;
2931
import reactor.netty.http.websocket.WebsocketOutbound;
3032

@@ -46,6 +48,8 @@ public class ReactorNettyWebSocketSession
4648

4749
private final int maxFramePayloadLength;
4850

51+
private final ChannelId channelId;
52+
4953

5054
/**
5155
* Constructor for the session, using the {@link #DEFAULT_FRAME_MAX_SIZE} value.
@@ -66,6 +70,16 @@ public ReactorNettyWebSocketSession(WebsocketInbound inbound, WebsocketOutbound
6670

6771
super(new WebSocketConnection(inbound, outbound), info, bufferFactory);
6872
this.maxFramePayloadLength = maxFramePayloadLength;
73+
this.channelId = ((ChannelOperations) inbound).channel().id();
74+
}
75+
76+
77+
/**
78+
* Return the id of the underlying Netty channel.
79+
* @since 5.3.4
80+
*/
81+
public ChannelId getChannelId() {
82+
return this.channelId;
6983
}
7084

7185

0 commit comments

Comments
 (0)