Files
java-tutorials/spring-5-reactive-security/src/main/java/com/baeldung/webflux/EmployeeWebSocketClient.java
T

22 lines
721 B
Java
Raw Normal View History

2019-11-01 00:35:30 +01:00
package com.baeldung.webflux;
import java.net.URI;
import org.springframework.web.reactive.socket.WebSocketMessage;
import org.springframework.web.reactive.socket.client.ReactorNettyWebSocketClient;
import org.springframework.web.reactive.socket.client.WebSocketClient;
public class EmployeeWebSocketClient {
public static void main(String[] args) {
WebSocketClient client = new ReactorNettyWebSocketClient();
client.execute(URI.create("ws://localhost:8080/employee-feed"), session -> session.receive()
.map(WebSocketMessage::getPayloadAsText)
.doOnNext(System.out::println)
.then())
.block(); // to subscribe and return the value
}
}