Package org.atmosphere.cpr

Examples of org.atmosphere.cpr.AtmosphereResource


    @Override
    protected void doGet(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=ISO-8859-1");

        AtmosphereResource e =
                (AtmosphereResource) request.getAttribute(AtmosphereServlet.ATMOSPHERE_RESOURCE);

        if (!e.getBroadcaster().getID().equals("GWT")){
            synchronized(e.getBroadcaster()){
                e.getBroadcaster().setID("GWT");
                e.getBroadcaster().getBroadcasterConfig().addFilter(new GWTBroadcasterFilter());
            }
        }

        sendKeepAlive(response.getOutputStream());
        e.suspend();
    }
View Full Code Here


abstract class BaseInjectableProvider implements InjectableProvider<Context, Type> {
    // The current {@link HttpServletRequest{
    @Context HttpServletRequest req;

    protected AtmosphereResource getAtmosphereResource(Class injectType, boolean session) {
        AtmosphereResource r = null;

        try {
            if (session) {
                if ((Boolean) req.getAttribute(AtmosphereServlet.SUPPORT_SESSION)) {
                    r = (AtmosphereResource) req.getSession().
View Full Code Here

                if (_intervalTimeoutTask != null)
                    _bayeux.startTimeout(_intervalTimeoutTask, _bayeux.getMaxInterval());
            }
        } else {
            synchronized (this) {
                AtmosphereResource oldContinuation = _continuation;
                _continuation = continuation;

                _bayeux.cancelTimeout(_intervalTimeoutTask);
                _accessed = _bayeux.getNow();

                if (oldContinuation == null) {
                    // This is the start of a long poll
                } else {
                    // This is the reload case: there is an outstanding connect,
                    // and the client issues a new connect.
                    // We return the old connect via complete() since we do not
                    // want to resume() otherwise the old connect will be
                    // redispatched and will overwrite the new connect.
                    try {
                        if (oldContinuation.getAtmosphereResourceEvent().isSuspended()) {
                            ((HttpServletResponse) oldContinuation.getResponse()).sendError(HttpServletResponse.SC_REQUEST_TIMEOUT);
                            oldContinuation.resume();
                        }
                    }
                    catch (Exception e) {
                        Log.debug(e);
                    }
View Full Code Here

        AtmosphereContinuationBayeux bayeux = (AtmosphereContinuationBayeux) _bayeux;
        if (bayeux != null) {
            for (Client c : bayeux.getClients()) {
                if (c instanceof AtmosphereBayeuxClient) {
                    AtmosphereBayeuxClient client = (AtmosphereBayeuxClient) c;
                    AtmosphereResource continuation = client.getContinuation();
                    client.setContinuation(null);
                    if (continuation != null && continuation.getAtmosphereResourceEvent().isSuspended()) {
                        try {
                            ((HttpServletResponse) continuation.getResponse()).sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
                        } catch (IOException e) {
                            Log.ignore(e);
                        }
                    }
                }
View Full Code Here

                }
               
                Broadcaster outsiderBroadcaster
                        = (Broadcaster) atmoResource.getAtmosphereConfig().getServletContext().getAttribute(follow);
                                   
                AtmosphereResource r = (AtmosphereResource)session.getAttribute("atmoResource");
                if (outsiderBroadcaster == null){
                    myBroadcasterFollower.broadcast(BEGIN_SCRIPT_TAG
                        + toJsonp("Invalid Twitter user ", follow)
                        + END_SCRIPT_TAG, r);
                    return;
View Full Code Here

                    }
                    break;
                case BROADCAST:
                case RESUME_ON_BROADCAST:
                    AtmosphereResource ar = (AtmosphereResource) servletReq.getAttribute(SUSPENDED_RESOURCE);
                    if (ar != null) {
                        r = ar;
                    }
                    broadcast(response, r, suspendTimeout);
                    break;
View Full Code Here

   * @param event
   * @param resourceUuid
   */
  public void post(Object event, String resourceUuid)
  {
    AtmosphereResource resource = AtmosphereResourceFactory.getDefault().find(resourceUuid);
    if (resource != null)
    {
      post(event, resource);
    }
  }
View Full Code Here

        framework.setAsyncSupport(new NettyCometSupport(framework.getAtmosphereConfig()) {
            @Override
            public Action suspended(AtmosphereRequest request, AtmosphereResponse response) throws IOException, ServletException {
                Action a = super.suspended(request, response);
                if (framework.getAtmosphereConfig().isSupportSession()) {
                    AtmosphereResource r = request.resource();
                    HttpSession s = request.getSession(true);
                    if (s != null) {
                        sessions.put(r.uuid(), request.getSession(true));
                    }
                }
                return a;
            }
View Full Code Here

        if (o == null) return;

        if (WebSocket.class.isAssignableFrom(o.getClass())) {
            WebSocket webSocket = WebSocket.class.cast(o);
            AtmosphereResource r = webSocket.resource();

            logger.trace("Closing {}", r != null ? r.uuid() : "NULL");

            try {
                webSocketProcessor.close(webSocket, 1005);
            } catch (Exception ex) {
                logger.error("{}", webSocket, ex);
View Full Code Here

            }
        }
    }

    void prepareForClose(final AtmosphereResponse response) throws UnsupportedEncodingException {
        AtmosphereResource r = response != null ? response.resource() : null;
        if (r == null || r.isSuspended() && !r.isResumed()) {
            keepAlive = false;
        }

        _close(response);
    }
View Full Code Here

TOP

Related Classes of org.atmosphere.cpr.AtmosphereResource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.