use of org.glassfish.jersey.media.sse.OutboundEvent in project jersey by jersey.
the class MessageStreamResource method putMessage.
/**
* Put a new message to the stream.
*
* The message will be broadcast to all registered SSE clients.
*
* @param message message to be broadcast.
*/
@PUT
@Consumes(MediaType.APPLICATION_JSON)
public void putMessage(final Message message) {
LOGGER.info("--> Message received.");
final OutboundEvent event = new OutboundEvent.Builder().id(String.valueOf(nextMessageId.getAndIncrement())).mediaType(MediaType.APPLICATION_JSON_TYPE).data(Message.class, message).build();
broadcaster.broadcast(event);
}
Aggregations