Browse Source

Expose ChannelId from ReactorNettyWebSocketSession

Closes gh-26485
pull/26513/head
Rossen Stoyanchev 5 years ago
parent
commit
eb7b206142
  1. 14
      spring-webflux/src/main/java/org/springframework/web/reactive/socket/adapter/ReactorNettyWebSocketSession.java

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

@ -18,6 +18,7 @@ package org.springframework.web.reactive.socket.adapter;
import java.util.function.Consumer; import java.util.function.Consumer;
import io.netty.channel.ChannelId;
import io.netty.handler.codec.http.websocketx.WebSocketFrame; import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import org.reactivestreams.Publisher; import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux; import reactor.core.publisher.Flux;
@ -25,6 +26,7 @@ import reactor.core.publisher.Mono;
import reactor.netty.Connection; import reactor.netty.Connection;
import reactor.netty.NettyInbound; import reactor.netty.NettyInbound;
import reactor.netty.NettyOutbound; import reactor.netty.NettyOutbound;
import reactor.netty.channel.ChannelOperations;
import reactor.netty.http.websocket.WebsocketInbound; import reactor.netty.http.websocket.WebsocketInbound;
import reactor.netty.http.websocket.WebsocketOutbound; import reactor.netty.http.websocket.WebsocketOutbound;
@ -46,6 +48,8 @@ public class ReactorNettyWebSocketSession
private final int maxFramePayloadLength; private final int maxFramePayloadLength;
private final ChannelId channelId;
/** /**
* Constructor for the session, using the {@link #DEFAULT_FRAME_MAX_SIZE} value. * Constructor for the session, using the {@link #DEFAULT_FRAME_MAX_SIZE} value.
@ -66,6 +70,16 @@ public class ReactorNettyWebSocketSession
super(new WebSocketConnection(inbound, outbound), info, bufferFactory); super(new WebSocketConnection(inbound, outbound), info, bufferFactory);
this.maxFramePayloadLength = maxFramePayloadLength; this.maxFramePayloadLength = maxFramePayloadLength;
this.channelId = ((ChannelOperations) inbound).channel().id();
}
/**
* Return the id of the underlying Netty channel.
* @since 5.3.4
*/
public ChannelId getChannelId() {
return this.channelId;
} }

Loading…
Cancel
Save