MQTT Events
Some lifetime events are fired by the <xref:Silverback.Messaging.Broker.MqttBroker> and can be handled using the following callbacks:
- <xref:Silverback.Messaging.Broker.Callbacks.IMqttClientConnectedCallback>
- <xref:Silverback.Messaging.Broker.Callbacks.IMqttClientDisconnectingCallback>
Example
In the following example a message is sent as soon as the client is connected.
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.AddSilverback()
.WithConnectionToMessageBroker(options => options
.AddMqtt())
.AddSingletonBrokerCallbacksHandler<ConnectionCallbackHandler>();
}
}