Class SseResource

  • All Implemented Interfaces:

    public class SseResource
    extends Object
    implements RESTResource,
    SSE Resource for pushing events to currently listening clients.
    Ivan Iliev - Initial contribution, Yordan Zhelev - Added Swagger annotations, Yannick Schaus - Add endpoints to track item state updates, Markus Rathgeb - Drop Glassfish dependency and use API only, Wouter Born - Rework SSE item state sinks for dropping Glassfish, Wouter Born - Migrated to OpenAPI annotations
    • Constructor Detail

      • SseResource

        public SseResource​( itemStatesEventBuilder)
    • Method Detail

      • deactivate

        public void deactivate()
      • broadcast

        public void broadcast​(Event event)
        Specified by:
        broadcast in interface
      • listen

        public void listen​(@Context
                           javax.servlet.http.HttpServletResponse response,
                           String eventFilter)
      • getStateEvents

        public void getStateEvents​(@Context
                                   javax.servlet.http.HttpServletResponse response)
        Subscribes the connecting client for state updates. It will initially only send a "ready" event with an unique connectionId that the client can use to dynamically alter the list of tracked items.
      • updateTrackedItems

        public Object updateTrackedItems​(@PathParam("connectionId")
                                         String connectionId,
                                         Set<String> itemNames)
        Alters the list of tracked items for a given state update connection
        connectionId - the connection Id to change
        itemNames - the list of items to track
      • handleEventBroadcastItemState

        public void handleEventBroadcastItemState​(ItemStateChangedEvent stateChangeEvent)
        Broadcasts a state event to all currently listening clients, after transforming it to a simple map.
        stateChangeEvent - the ItemStateChangedEvent containing the new state