Package org.richfaces.application.push

Examples of org.richfaces.application.push.Topic


    @Override
    public synchronized void destroy() {
        active = false;

        for (TopicKey key : successfulSubscriptions) {
            Topic topic = topicsContext.getTopic(key);
            topic.publishEvent(new SessionUnsubscriptionEvent(topic, key, this));
        }

        try {
            disconnect();
        } catch (Exception e) {
View Full Code Here


        createSubscriptions(topicKeys);
    }

    private void createSubscriptions(Iterable<TopicKey> topicKeys) {
        for (TopicKey topicKey : topicKeys) {
            Topic pushTopic = topicsContext.getOrCreateTopic(topicKey);

            String errorMessage = null;

            if (pushTopic == null) {
                errorMessage = MessageFormat.format("Topic ''{0}'' is not configured", topicKey.getTopicAddress());
            } else {
                try {
                    // TODO - publish another events
                    pushTopic.checkSubscription(this);
                } catch (SubscriptionFailureException e) {
                    if (e.getMessage() != null) {
                        errorMessage = e.getMessage();
                    } else {
                        errorMessage = MessageFormat.format("Unknown error connecting to ''{0}'' topic",
                                topicKey.getTopicAddress());
                    }
                }
            }

            if (errorMessage != null) {
                failedSubscriptions.put(topicKey, errorMessage);
            } else {
                pushTopic.publishEvent(new SessionSubscriptionEvent(pushTopic, topicKey, this));
                successfulSubscriptions.add(topicKey);
            }
        }
    }
View Full Code Here

      e.printStackTrace();
    }
      
        TopicsContext topicsContext = TopicsContext.lookup();
       
        Topic topic = topicsContext.getOrCreateTopic(new TopicKey("inmobles"));
       
        topic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
       
        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()));
View Full Code Here

      e.printStackTrace();
    }
      
        TopicsContext topicsContext = TopicsContext.lookup();
       
        Topic topic = topicsContext.getOrCreateTopic(new TopicKey("inmobles"));
       
        topic.setMessageDataSerializer(DefaultMessageDataSerializer.instance());
       
        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()));
View Full Code Here

TOP

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

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.