Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hu.cobalt.anytime.controller;
- import hu.cobalt.anytime.entity.Bookable;
- import org.springframework.http.MediaType;
- import org.springframework.web.bind.annotation.*;
- import reactor.core.publisher.DirectProcessor;
- import reactor.core.publisher.Flux;
- import reactor.core.publisher.FluxProcessor;
- import reactor.core.publisher.FluxSink;
- import java.time.ZonedDateTime;
- @RestController
- @RequestMapping("/waiter")
- public class WaiterController {
- FluxProcessor<Object, Object> processor = DirectProcessor.create().serialize();
- FluxSink<Object> sink = processor.sink();
- @PostMapping(value = "/add")
- void addWaiterCall(@RequestBody WaiterCall waiterCall) {
- sink.next(waiterCall);
- }
- @GetMapping(value = "", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
- Flux<Object> getWaiterCallEvents() {
- return processor;
- }
- static class WaiterCall {
- Bookable bookable;
- ZonedDateTime time = ZonedDateTime.now();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement