Package org.richfaces.application.push

Examples of org.richfaces.application.push.Session


       
        topic.addTopicListener(new SessionTopicListener() {
           
            public void processUnsubscriptionEvent(SessionUnsubscriptionEvent event) throws EventAbortedException {
                TopicKey topicKey = event.getTopicKey();
                Session session = event.getSession();
                System.out.println(MessageFormat.format("Session {0} disconnected from {1}", session.getId(), topicKey.getTopicAddress()));
            }
           
            public void processSubscriptionEvent(SessionSubscriptionEvent event) throws EventAbortedException {
                TopicKey topicKey = event.getTopicKey();
                Session session = event.getSession();
               
                FacesContext facesContext = FacesContext.getCurrentInstance();
                HttpServletRequest hsr = (HttpServletRequest) facesContext.getExternalContext().getRequest();
               
                System.out.println(MessageFormat.format("Session {0} connected to {1} from {2}", session.getId(),
                    topicKey.getTopicAddress(), hsr.getRemoteAddr()));
            }
           
            public void processPreSubscriptionEvent(SessionPreSubscriptionEvent event) throws EventAbortedException {
                ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
View Full Code Here


       
        topic.addTopicListener(new SessionTopicListener() {
           
            public void processUnsubscriptionEvent(SessionUnsubscriptionEvent event) throws EventAbortedException {
                TopicKey topicKey = event.getTopicKey();
                Session session = event.getSession();
                System.out.println(MessageFormat.format("Session {0} disconnected from {1}", session.getId(), topicKey.getTopicAddress()));
            }
           
            public void processSubscriptionEvent(SessionSubscriptionEvent event) throws EventAbortedException {
                TopicKey topicKey = event.getTopicKey();
                Session session = event.getSession();
               
                FacesContext facesContext = FacesContext.getCurrentInstance();
                HttpServletRequest hsr = (HttpServletRequest) facesContext.getExternalContext().getRequest();
               
                System.out.println(MessageFormat.format("Session {0} connected to {1} from {2}", session.getId(),
                    topicKey.getTopicAddress(), hsr.getRemoteAddr()));
            }
           
            public void processPreSubscriptionEvent(SessionPreSubscriptionEvent event) throws EventAbortedException {
                ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
View Full Code Here

        PushContext pushContext = pushContextFactory.getPushContext();

        String forgetPushSessionId = externalContext.getRequestParameterMap().get(FORGET_PUSH_SESSION_ID_PARAM);
        if (forgetPushSessionId != null) {
            Session oldSession = pushContext.getSessionManager().getPushSession(forgetPushSessionId);
            if (oldSession != null) {
                oldSession.invalidate();
            }
        }

        Session session = pushContext.getSessionFactory().createSession(UUID.randomUUID().toString());

        String[] topicNames = externalContext.getRequestParameterValuesMap().get(PUSH_TOPIC_PARAM);

        if (topicNames == null) {
            throw new IllegalArgumentException(PUSH_TOPIC_PARAM + " request parameter must be present");
        }

        session.subscribe(topicNames);

        Map<String, Object> subscriptionData = new HashMap<String, Object>(4);
        subscriptionData.put("sessionId", session.getId());

        Map<TopicKey, String> failedSubscriptions = session.getFailedSubscriptions();
        subscriptionData.put("failures", getFailuresMap(failedSubscriptions));

        Writer outWriter = facesContext.getExternalContext().getResponseOutputWriter();
        ScriptUtils.appendScript(outWriter, subscriptionData);
    }
View Full Code Here

TOP

Related Classes of org.richfaces.application.push.Session

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.