Class ServerSentEventsAdminController

java.lang.Object
org.tailormap.api.controller.admin.ServerSentEventsAdminController

@RestController public class ServerSentEventsAdminController extends Object
  • Constructor Details

    • ServerSentEventsAdminController

      public ServerSentEventsAdminController(ch.rasc.sse.eventbus.SseEventBus eventBus, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • entityEvents

      @GetMapping(path="${tailormap-api.admin.base-path}/events/{clientId}") public org.springframework.web.servlet.mvc.method.annotation.SseEmitter entityEvents(@PathVariable("clientId") String clientId)
      Endpoint for the single-page admin frontend to receive updates to entities from other windows. The frontend does not load all data on each navigation as a traditional frontend and loads and stores entities in memory. This requires updating stale entities when these get updated in other windows (from other sessions or the same session in a different browser tab), otherwise data might get lost or overwritten.

      This endpoint uses Server-sent events, which technically is a long-poll HTTP request which allows unidirectional server-initiated communication. Not bidirectional like websockets, but simpler because of the long-poll HTTP request. The webserver should ideally use HTTP/2 or higher because HTTP/1.1 limits the amount of simultaneous connections to a server per browser to 6.

      Returns:
      the server-sent events emitter
    • keepAlive

      @Scheduled(fixedRate=60000L) public void keepAlive() throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException