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.BrokerAvailabilityEvent; 18 19 import hunt.util.ApplicationEvent; 20 import std.conv; 21 22 /** 23 * Event raised when a broker's availability changes. 24 * 25 * @author Andy Wilkinson 26 */ 27 class BrokerAvailabilityEvent : ApplicationEvent { 28 29 private bool brokerAvailable; 30 31 32 /** 33 * Creates a new {@code BrokerAvailabilityEvent}. 34 * 35 * @param brokerAvailable {@code true} if the broker is available, {@code} 36 * false otherwise 37 * @param source the component that is acting as the broker, or as a relay 38 * for an external broker, that has changed availability. Must not be {@code 39 * null}. 40 */ 41 this(bool brokerAvailable, Object source) { 42 super(source); 43 this.brokerAvailable = brokerAvailable; 44 } 45 46 bool isBrokerAvailable() { 47 return this.brokerAvailable; 48 } 49 50 override 51 string toString() { 52 return "BrokerAvailabilityEvent[available=" ~ this.brokerAvailable.to!string() 53 ~ ", " ~ getSource().toString() ~ "]"; 54 } 55 56 }