Search in sources :

Example 1 with Broadcastable

use of org.atmosphere.jersey.Broadcastable in project joynr by bmwcarit.

the class LongPollingMessagingDelegate method openChannel.

/*
     * Opens a channel for long polling.
     *
     * @param ccid
     *            the ID of the channel
     * @param atmosphereTrackingId
     *            the tracking ID
     * @return
     * @throws JoynrHttpException
     *             if no channel with the given ID was found (e.g. because it
     *             wasn't created before) or if the tracking ID wasn't set
     */
public Broadcastable openChannel(String ccid, String atmosphereTrackingId) {
    throwExceptionIfTrackingIdnotSet(atmosphereTrackingId);
    log.debug("GET Channels open long poll channelId: {} trackingId: {}", ccid, atmosphereTrackingId);
    // NOTE: as of Atmosphere 0.8.5: even though the parameter is set
    // not to create the broadcaster if not
    // found, if the
    // broadcaster is found, but set to "destroyed" then it is recreated
    // TODO when is a broadcaster "destroyed" ???
    Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(BounceProxyBroadcaster.class, ccid, false);
    if (broadcaster == null) {
        log.error("no broadcaster registered for channel {}", ccid);
        // broadcaster not found for given ccid
        throw new JoynrHttpException(Status.BAD_REQUEST, JOYNRMESSAGINGERROR_CHANNELNOTFOUND);
    }
    // in the cache
    return new Broadcastable(broadcaster);
}
Also used : Broadcastable(org.atmosphere.jersey.Broadcastable) JoynrHttpException(io.joynr.communications.exceptions.JoynrHttpException) Broadcaster(org.atmosphere.cpr.Broadcaster)

Aggregations

JoynrHttpException (io.joynr.communications.exceptions.JoynrHttpException)1 Broadcaster (org.atmosphere.cpr.Broadcaster)1 Broadcastable (org.atmosphere.jersey.Broadcastable)1