*/
@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);
}