本文整理汇总了Java中org.glassfish.jersey.media.sse.SseFeature.SERVER_SENT_EVENTS属性的典型用法代码示例。如果您正苦于以下问题:Java SseFeature.SERVER_SENT_EVENTS属性的具体用法?Java SseFeature.SERVER_SENT_EVENTS怎么用?Java SseFeature.SERVER_SENT_EVENTS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.glassfish.jersey.media.sse.SseFeature
的用法示例。
在下文中一共展示了SseFeature.SERVER_SENT_EVENTS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listenToBroadcast
@GET
@Path("/Notifications/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@RolesAllowed({GlobalConstants.ROLE_SHOP_ADMIN})
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
final EventOutput eventOutput = new EventOutput();
if(Globals.broadcasterMap.get(shopID)!=null)
{
SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
broadcasterOne.add(eventOutput);
}
else
{
SseBroadcaster broadcasterTwo = new SseBroadcaster();
broadcasterTwo.add(eventOutput);
Globals.broadcasterMap.put(shopID,broadcasterTwo);
}
return eventOutput;
}
示例2: listenToBroadcast
@GET
@Path("/Notifications/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
final EventOutput eventOutput = new EventOutput();
if(Globals.broadcasterMap.get(shopID)!=null)
{
SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
broadcasterOne.add(eventOutput);
}
else
{
SseBroadcaster broadcasterTwo = new SseBroadcaster();
broadcasterTwo.add(eventOutput);
Globals.broadcasterMap.put(shopID,broadcasterTwo);
}
return eventOutput;
}
示例3: listenToBroadcast
@GET
@Path("/Notifications/{EndUserID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("EndUserID")int endUserID) {
final EventOutput eventOutput = new EventOutput();
if(Globals.broadcasterMapEndUser.get(endUserID)!=null)
{
SseBroadcaster broadcasterOne = Globals.broadcasterMapEndUser.get(endUserID);
broadcasterOne.add(eventOutput);
}
else
{
SseBroadcaster broadcasterTwo = new SseBroadcaster();
broadcasterTwo.add(eventOutput);
Globals.broadcasterMapEndUser.put(endUserID,broadcasterTwo);
}
return eventOutput;
}
示例4: listenToBroadcast
@GET
@Path("/{ShopID}")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast(@PathParam("ShopID")int shopID) {
final EventOutput eventOutput = new EventOutput();
if(Globals.broadcasterMap.get(shopID)!=null)
{
SseBroadcaster broadcasterOne = Globals.broadcasterMap.get(shopID);
broadcasterOne.add(eventOutput);
}
else
{
SseBroadcaster broadcasterTwo = new SseBroadcaster();
broadcasterTwo.add(eventOutput);
Globals.broadcasterMap.put(shopID,broadcasterTwo);
}
return eventOutput;
}
示例5: events
@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput events() {
final EventOutput eventOutput = new EventOutput();
if (!broadcaster.add(eventOutput)) {
// 503 -> 5s delayed client reconnect attempt.
throw new ServiceUnavailableException(5L);
}
try {
eventOutput.write(event());
} catch (final IOException ioe) {
// NO-OP.
}
return eventOutput;
}
示例6: listenToEvents
@GET
@PermitAll
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToEvents(@QueryParam("token") String token) {
String removedToken = SLTRegister.remove(token);
if (removedToken == null) {
return null;
}
final EventOutput eventOutput = new EventOutput();
sseBroadcaster.add(eventOutput);
return eventOutput;
}
示例7: getServerSentEvents
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
@Path("id-only")
public EventOutput getServerSentEvents(
@NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
return createEventOutput(subscriptionRequestParams, false);
}
示例8: getServerSentEventsFull
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
@NoCache
public EventOutput getServerSentEventsFull(
@NotNull @Valid @BeanParam SubscriptionRequestParams subscriptionRequestParams) {
return createEventOutput(subscriptionRequestParams, true);
}
示例9: errors
@GET
@Path("/events.stream")
@Produces(SseFeature.SERVER_SENT_EVENTS)
@ApiOperation(value = "Get Event Stream of Application Events", notes = "Returns a continuous stream of application events using Server-Sent Events.")
public EventOutput errors() {
final EventOutput eventOutput = new EventOutput();
BROADCASTER.add(eventOutput);
return eventOutput;
}
示例10: fetch
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput fetch() {
final EventOutput eventOutput = new EventOutput();
new Thread(new Runnable() {
@Override
public void run() {
try {
for (int i = 0; i < 10; i++) {
final OutboundEvent.Builder eventBuilder = new OutboundEvent.Builder();
eventBuilder.name("message-to-client");
eventBuilder.data(String.class,
"Hello world " + i + "!");
final OutboundEvent event = eventBuilder.build();
eventOutput.write(event);
}
} catch (IOException e) {
throw new RuntimeException(
"Error when writing the event.", e);
} finally {
try {
eventOutput.close();
} catch (IOException ioClose) {
throw new RuntimeException(
"Error when closing the event output.",
ioClose);
}
}
}
}).start();
return eventOutput;
}
示例11: fetch
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput fetch(
@HeaderParam(SseFeature.LAST_EVENT_ID_HEADER) String lastEventId) {
if (!Strings.isNullOrEmpty(lastEventId)) {
LOGGER.debug("Found Last-Event-ID header: {}", lastEventId);
}
final EventOutput output = new EventOutput();
if (!broadcaster.add(output)) {
throw new ServiceUnavailableException(RETRY_AFTER.toSeconds());
}
return output;
}
示例12: emitEvents
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput emitEvents() {
final EventOutput eventOutput = new EventOutput();
new Thread(new Runnable() {
@Override
public void run() {
try {
for (int i = 0; i < 25; i++) {
final OutboundEvent.Builder eventBuilder
= new OutboundEvent.Builder();
eventBuilder.name("message-to-client");
eventBuilder.data(String.class,
"Hello world " + i + "!");
final OutboundEvent event = eventBuilder.build();
eventOutput.write(event);
}
} catch (IOException e) {
throw new RuntimeException(
"Error when writing the event.", e);
} finally {
try {
eventOutput.close();
} catch (IOException ioClose) {
throw new RuntimeException(
"Error when closing the event output.", ioClose);
}
}
}
}).start();
return eventOutput;
}
示例13: listenToBroadcast
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast() {
final EventOutput eventOutput = new EventOutput();
boolean val=this.broadcaster.add(eventOutput);
System.out.println("brcd2:"+val);
return eventOutput;
}
示例14: itemEvents
@GET
@Path("events")
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput itemEvents() {
final EventOutput eventOutput = new EventOutput();
BROADCASTER.add(eventOutput);
return eventOutput;
}
示例15: listenToBroadcast
@GET
@Produces(SseFeature.SERVER_SENT_EVENTS)
public EventOutput listenToBroadcast() {
final EventOutput eventOutput = new EventOutput();
this.broadcaster.add(eventOutput);
return eventOutput;
}