// TODO ability to change eventMapping dynamically public AbstractEventManager(ActionMapping<EventAction> eventMapping) { if (eventMapping == null) throw new IllegalArgumentException("EventMapping can't be null"); this.eventMapping = eventMapping; for (Iterator<EventAction> it = eventMapping.getActionsIterator(); it.hasNext(); ) it.next().setEventSender(this); }
public void onUnsubscribe(String sessionId, WampUnsubscribeMessage wampUnsubscribeMessage) { EventAction e = eventMapping.getAction(wampUnsubscribeMessage.getTopicId()); if (e != null) e.unsubscribe(sessionId); else if (log.isDebugEnabled()) log.debug( "unable to unsubscribe : action name doesn't not exist " + wampUnsubscribeMessage.getTopicId()); }
// TODO new publish public void onPublish(String sessionId, WampPublishMessage wampPublishMessage) throws SerializationException { EventAction e = eventMapping.getAction(wampPublishMessage.getTopicId()); if (e != null) { OutputWampEventMessage msg = new OutputWampEventMessage(); msg.setTopicId(wampPublishMessage.getTopicId()); msg.setEvent(wampPublishMessage.getEvent()); // e.publishTo think about it List<String> publishList = e.publishTo(getPublishList(e, sessionId, wampPublishMessage), wampPublishMessage, msg); if (publishList != null) for (String s : publishList) sendEvent(s, msg); } else if (log.isDebugEnabled()) log.debug( "unable to publish : action name doesn't not exist " + wampPublishMessage.getTopicId()); }
public void onClose(String sessionId, int closeCode) { for (Iterator<EventAction> it = eventMapping.getActionsIterator(); it.hasNext(); ) it.next().unsubscribe(sessionId); }