Package org.atmosphere.cpr

Examples of org.atmosphere.cpr.Meteor.broadcast()


        logger.info("BEGIN SimpleAction.openCometChannel()");
        Meteor m = Meteor.build(req, list, null);
        m.setBroadcaster(b);
        req.getSession().setAttribute("meteor", m);
        m.suspend(-1);
        m.broadcast(req.getServerName()
                + "__has suspended a connection from " + req.getRemoteAddr());
        return null;
    }

    public ActionForward sendCometMsg(ActionMapping mapping, ActionForm _form, HttpServletRequest req, HttpServletResponse res) throws Exception {
View Full Code Here


        logger.info("meteor: " + m);
        res.setCharacterEncoding("UTF-8");
        String value = req.getParameter("value");
        logger.debug("value: " + value);

        m.broadcast("<script>parent.cometMsg('Broadcast: " + value + "');</script>");
        res.getWriter().write("{message:'success'}");
        res.getWriter().flush();
        return null;
    }
}
View Full Code Here

        public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException {
            final Meteor m = Meteor.build(req);
            req.getSession().setAttribute("meteor", m);
            m.suspend(5000, false);
           
            m.broadcast("resume");
            m.addListener(new AtmosphereResourceEventListener(){

                @Override
                public void onSuspend(final AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event){
                }
View Full Code Here

        req.getSession().setAttribute("meteor", m);

        res.setContentType("text/html;charset=ISO-8859-1");

        m.suspend(-1);
        m.broadcast(req.getServerName() + "__has suspended a connection from " + req.getRemoteAddr());
    }

    /**
     * Re-use the {@link Meteor} created onthe first GET for broadcasting message.
     *
 
View Full Code Here

        String action = req.getParameterValues("action")[0];
        String name = req.getParameterValues("name")[0];

        if ("login".equals(action)) {
            req.getSession().setAttribute("name", name);
            m.broadcast("System Message from " + req.getServerName() + "__" + name + " has joined.");
            res.getWriter().write("success");
            res.getWriter().flush();
        } else if ("post".equals(action)) {
            String message = req.getParameterValues("message")[0];
            m.broadcast(name + "__" + message);
View Full Code Here

            m.broadcast("System Message from " + req.getServerName() + "__" + name + " has joined.");
            res.getWriter().write("success");
            res.getWriter().flush();
        } else if ("post".equals(action)) {
            String message = req.getParameterValues("message")[0];
            m.broadcast(name + "__" + message);
            res.getWriter().write("success");
            res.getWriter().flush();
        } else {
            res.setStatus(422);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.