@Suspend(contentType = MediaType.APPLICATION_JSON) @GET public String suspend(@Context AtmosphereResource resource) { resource.setBroadcaster(BroadcastHelper.getTradeBroadcaster()); return ""; } }
public Broadcaster createBroadcaster(String ID) { Broadcaster b = BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, ID); atm.setBroadcaster(b); return b; } }
/** * Creates channel (named {@link Broadcaster} in Atmosphere) based on the {@link org.atmosphere.cpr.AtmosphereRequest#getPathInfo()} * * @param resource An {@link AtmosphereResource} * @return */ public boolean apply(AtmosphereResource resource) { String pathInfo = resource.getRequest().getPathInfo(); BroadcasterFactory f = resource.getAtmosphereConfig().getBroadcasterFactory(); if (pathInfo == null) { resource.setBroadcaster(f.lookup("/*")); return true; } final Broadcaster b = f.lookup(pathInfo, true); resource.setBroadcaster(b); return true; } }
+ broadcaster.getID()); ar.setBroadcaster(broadcaster);
/** * This is the main entrypoint on the server that you will want to hook into and override. * This method is called when a client has request a new connection. Best practice is to do all your * required setup here and tie the AtmosphereResource to a Broadcaster, but do not send anything to * the client yet. If you wish to do so it is best to let the client send a notification to the server * using the {@link AtmosphereClient#post} method in the onConnected event. * * @param resource * @return * @throws ServletException * @throws IOException */ public int doComet(GwtAtmosphereResource resource) throws ServletException, IOException { Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(Broadcaster.class, GWT_BROADCASTER_ID); if (broadcaster == null) { broadcaster = BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, GWT_BROADCASTER_ID); } resource.getAtmosphereResource().setBroadcaster(broadcaster); return NO_TIMEOUT; }
/** * This is the main entrypoint on the server that you will want to hook into and override. * This method is called when a client has request a new connection. Best practice is to do all your * required setup here and tie the AtmosphereResource to a Broadcaster, but do not send anything to * the client yet. If you wish to do so it is best to let the client send a notification to the server * using the {@link AtmosphereClient#post} method in the onConnected event. * * @param resource * @return * @throws ServletException * @throws IOException */ public int doComet(GwtAtmosphereResource resource) throws ServletException, IOException { Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(Broadcaster.class, GWT_BROADCASTER_ID); if (broadcaster == null) { broadcaster = BroadcasterFactory.getDefault().get(DefaultBroadcaster.class, GWT_BROADCASTER_ID); } resource.getAtmosphereResource().setBroadcaster(broadcaster); return NO_TIMEOUT; }
r.setBroadcaster(bcaster); executeSuspend(r, timeout, resumeOnBroadcast, null, request, response, writeEntity); } else { throw new IllegalStateException(e.getMessage()); r.setBroadcaster(config.getBroadcasterFactory().lookup(c, topic, true));
@Override public void onRequest() { TesterBroadcaster broadcaster = (TesterBroadcaster) eventBus.getBroadcaster(); AtmosphereResource atmosphereResource = new AtmosphereResourceImpl(); AtmosphereRequest atmosphereRequest = AtmosphereRequest.wrap(wicketTester.getRequest()); AtmosphereResponse atmosphereResponse = AtmosphereResponse.wrap(wicketTester.getResponse()); TesterAsyncSupport asyncSupport = new TesterAsyncSupport(); atmosphereResource.initialize(broadcaster.getApplicationConfig(), broadcaster, atmosphereRequest, atmosphereResponse, asyncSupport, new AtmosphereHandlerAdapter()); atmosphereResource.setBroadcaster(broadcaster); broadcaster.addAtmosphereResource(atmosphereResource); String uuid = atmosphereResource.uuid(); Page page = getComponent().getPage(); page.setMetaData(ATMOSPHERE_UUID, uuid); eventBus.registerPage(uuid, page); } }