|
|
@ -15,10 +15,13 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.springframework.web.reactive.socket.adapter; |
|
|
|
package org.springframework.web.reactive.socket.adapter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
|
|
|
|
import reactor.netty.Connection; |
|
|
|
import reactor.netty.NettyInbound; |
|
|
|
import reactor.netty.NettyInbound; |
|
|
|
import reactor.netty.NettyOutbound; |
|
|
|
import reactor.netty.NettyOutbound; |
|
|
|
import reactor.netty.http.websocket.WebsocketInbound; |
|
|
|
import reactor.netty.http.websocket.WebsocketInbound; |
|
|
@ -93,6 +96,13 @@ public class ReactorNettyWebSocketSession |
|
|
|
.then(); |
|
|
|
.then(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean isOpen() { |
|
|
|
|
|
|
|
DisposedCallback callback = new DisposedCallback(); |
|
|
|
|
|
|
|
getDelegate().getInbound().withConnection(callback); |
|
|
|
|
|
|
|
return callback.isDisposed(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Mono<Void> close(CloseStatus status) { |
|
|
|
public Mono<Void> close(CloseStatus status) { |
|
|
|
// this will notify WebSocketInbound.receiveCloseStatus()
|
|
|
|
// this will notify WebSocketInbound.receiveCloseStatus()
|
|
|
@ -129,4 +139,19 @@ public class ReactorNettyWebSocketSession |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static class DisposedCallback implements Consumer<Connection> { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean disposed; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean isDisposed() { |
|
|
|
|
|
|
|
return this.disposed; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void accept(Connection connection) { |
|
|
|
|
|
|
|
this.disposed = connection.isDisposed(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|