Example usage for org.springframework.web.reactive.socket WebSocketSession send

List of usage examples for org.springframework.web.reactive.socket WebSocketSession send

Introduction

In this page you can find the example usage for org.springframework.web.reactive.socket WebSocketSession send.

Prototype

Mono<Void> send(Publisher<WebSocketMessage> messages);

Source Link

Document

Give a source of outgoing messages, write the messages and return a Mono that completes when the source completes and writing is done.

Usage

From source file:top.zhacker.ms.reactor.webflux.controllers.EchoWebSocketHandler.java

@Override
public Mono<Void> handle(WebSocketSession session) {
    // Use retain() for Reactor Netty
    return session
            .send(session.receive().doOnNext(WebSocketMessage::retain).delayElements(Duration.ofSeconds(2)));
}

From source file:org.springframework.cloud.gateway.test.websocket.WebSocketIntegrationTests.java

private static Mono<Void> doSend(WebSocketSession session, Publisher<WebSocketMessage> output) {
    return session.send(output);
    // workaround for suspected RxNetty WebSocket client issue
    // https://github.com/ReactiveX/RxNetty/issues/560
    // return session.send(Mono.delay(Duration.ofMillis(100)).thenMany(output));
}