Search in sources :

Example 1 with EventOutput

use of org.glassfish.jersey.media.sse.EventOutput in project jersey by jersey.

the class FlightSimResource method connect.

@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput connect() {
    EventOutput output = new EventOutput();
    SimEngine.register(output);
    return output;
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with EventOutput

use of org.glassfish.jersey.media.sse.EventOutput in project jersey by jersey.

the class MessageStreamResource method getMessageStream.

/**
     * Get the new SSE message stream channel.
     *
     * @return new SSE message stream channel.
     */
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput getMessageStream() {
    LOGGER.info("--> SSE connection received.");
    final EventOutput eventOutput = new EventOutput();
    broadcaster.add(eventOutput);
    return eventOutput;
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with EventOutput

use of org.glassfish.jersey.media.sse.EventOutput in project javaee7-samples by javaee-samples.

the class MyResource method itemEvents.

@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput itemEvents() {
    final EventOutput eventOutput = new EventOutput();
    BROADCASTER.add(eventOutput);
    return eventOutput;
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with EventOutput

use of org.glassfish.jersey.media.sse.EventOutput in project jersey by jersey.

the class DomainResource method getProgress.

@Path("process/{id}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@GET
public EventOutput getProgress(@PathParam("id") int id, @DefaultValue("false") @QueryParam("testSource") boolean testSource) {
    final Process process = processes.get(id);
    if (process != null) {
        if (testSource) {
            process.release();
        }
        final EventOutput eventOutput = new EventOutput();
        process.getBroadcaster().add(eventOutput);
        return eventOutput;
    } else {
        throw new NotFoundException();
    }
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with EventOutput

use of org.glassfish.jersey.media.sse.EventOutput in project jersey by jersey.

the class ServerSentEventsResource method close.

@DELETE
public void close() throws IOException {
    eventOutput.close();
    ServerSentEventsResource.setEventOutput(new EventOutput());
}
Also used : EventOutput(org.glassfish.jersey.media.sse.EventOutput) DELETE(javax.ws.rs.DELETE)

Aggregations

EventOutput (org.glassfish.jersey.media.sse.EventOutput)8 Produces (javax.ws.rs.Produces)7 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 ServiceUnavailableException (javax.ws.rs.ServiceUnavailableException)2 DELETE (javax.ws.rs.DELETE)1 NotFoundException (javax.ws.rs.NotFoundException)1 POST (javax.ws.rs.POST)1 OutboundEvent (org.glassfish.jersey.media.sse.OutboundEvent)1