Example usage for org.springframework.http.codec ServerSentEvent builder

List of usage examples for org.springframework.http.codec ServerSentEvent builder

Introduction

In this page you can find the example usage for org.springframework.http.codec ServerSentEvent builder.

Prototype

public static <T> Builder<T> builder(T data) 

Source Link

Document

Return a builder for a SseEvent , populated with the give #data() data .

Usage

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

@GetMapping("/sse/event")
Flux<ServerSentEvent<String>> event() {
    return Flux.interval(Duration.ofSeconds(1))
            .map(l -> ServerSentEvent.builder("foo\nbar").comment("bar\nbaz").id(Long.toString(l)).build());
}

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

@PostMapping("/sse/receive/{val}")
public void receive(@PathVariable("val") String s) {
    replayProcessor.onNext(ServerSentEvent.builder(s).build());
}