1 /* 2 * Copyright 2002-2018 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 module hunt.stomp.simp.broker.SubscriptionRegistry; 18 19 import hunt.stomp.Message; 20 import hunt.collection.MultiValueMap; 21 22 /** 23 * A registry of subscription by session that allows looking up subscriptions. 24 * 25 * @author Rossen Stoyanchev 26 * @since 4.0 27 */ 28 interface SubscriptionRegistry { 29 30 /** 31 * Register a subscription represented by the given message. 32 * @param subscribeMessage the subscription request 33 */ 34 void registerSubscription(MessageBase subscribeMessage); 35 36 /** 37 * Unregister a subscription. 38 * @param unsubscribeMessage the request to unsubscribe 39 */ 40 void unregisterSubscription(MessageBase unsubscribeMessage); 41 42 /** 43 * Remove all subscriptions associated with the given sessionId. 44 */ 45 void unregisterAllSubscriptions(string sessionId); 46 47 /** 48 * Find all subscriptions that should receive the given message. 49 * The map returned is safe to iterate and will never be modified. 50 * @param message the message 51 * @return a {@code MultiValueMap} with sessionId-subscriptionId pairs 52 * (possibly empty) 53 */ 54 MultiValueMap!(string, string) findSubscriptions(MessageBase message); 55 56 }