1. 24 6月, 2016 2 次提交
    • S
      Take in account Rossen and Arjen feedbacks · 3c80c19c
      Sebastien Deleuze 提交于
      3c80c19c
    • S
      Add Server-Sent Events support · 90048122
      Sebastien Deleuze 提交于
      Flux<SseEvent> is Spring Web Reactive equivalent to Spring MVC
      SseEmitter type. It allows to send Server-Sent Events in a reactive way.
      Sending Flux<String> or Flux<Pojo> is equivalent to sending
      Flux<SseEvent> with the data property set to the String or
      Pojo value. For example:
      
      @RestController
      public class SseController {
      
      	@RequestMapping("/sse/string")
      	Flux<String> string() {
      		return Flux.interval(Duration.ofSeconds(1)).map(l -> "foo " + l);
      	}
      
      	@RequestMapping("/sse/person")
      	Flux<Person> person() {
      		return Flux.interval(Duration.ofSeconds(1)).map(l -> new Person(Long.toString(l), "foo", "bar"));
      	}
      
      	@RequestMapping("/sse-raw")
      	Flux<SseEvent> sse() {
      		return Flux.interval(Duration.ofSeconds(1)).map(l -> {
      			SseEvent event = new SseEvent();
      			event.setId(Long.toString(l));
      			event.setData("foo\nbar");
      			event.setComment("bar\nbaz");
      			return event;
      		});
      	}
      }
      90048122