Package org.directwebremoting

Examples of org.directwebremoting.Hub


     */
    public void publish(String topic, RealRawData data)
    {
        WebContext webContext = WebContextFactory.get();
        ConverterManager converterManager = webContext.getContainer().getBean(ConverterManager.class);
        Hub hub = HubFactory.get();

        MessageEvent event = new DefaultMessageEvent(hub, converterManager, data);
        hub.publish(topic, event);
    }
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public void subscribe(String topic, String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        final ScriptSession session = webContext.getScriptSession();

        // Create a subscription block
        BrowserMessageListener subscription = new BrowserMessageListener(session, topic, subscriptionId);

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        if (subscriptions == null)
        {
            subscriptions = new HashMap<String, BrowserMessageListener>();
        }
        subscriptions.put(subscriptionId, subscription);
        session.setAttribute(ATTRIBUTE_SUBSCRIPTIONS, subscriptions);

        hub.subscribe(subscription.topic, subscription);
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public boolean unsubscribe(String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        ScriptSession session = webContext.getScriptSession();

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        BrowserMessageListener subscription = subscriptions.get(subscriptionId);

        return hub.unsubscribe(subscription.topic, subscription);
    }
View Full Code Here

TOP

Related Classes of org.directwebremoting.Hub

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.