@GET @Path("events") @Produces(SseFeature.SERVER_SENT_EVENTS) public EventOutput itemEvents() { final EventOutput eventOutput = new EventOutput(); BROADCASTER.add(eventOutput); return eventOutput; }
@GET @Path("events") @Produces(SseFeature.SERVER_SENT_EVENTS) public EventOutput subscribe() { EventOutput eventOutput = new EventOutput(); broadcaster.add(eventOutput); return eventOutput; }
@GET @Produces(SseFeature.SERVER_SENT_EVENTS) public EventOutput get() { EventOutput output = new EventOutput(); broadcaster.add(output); scheduler.scheduleAtFixedRate(this::broadcastStatistics, 0, 1000, TimeUnit.MILLISECONDS); return output; }
public void registerNewClient(EventOutput eventOutput) { sseBroadcaster.add(eventOutput); OutboundEvent event = eventBuilder .name("new-client") .mediaType(MediaType.TEXT_PLAIN_TYPE) .data(String.class, "One more client") .build(); sseBroadcaster.broadcast(event); }