private async Task ConnectAsync() { _logger.LogInformation("Connecting to broker with configuration {@Configuration}", _serverConfig); await _client.ConnectAsync(_serverConfig); _logger.LogInformation("Connected succesfully"); _client.MessageReceivedAsync += HandleMessageAsync; }
public void Run() { // register event handlers this.LocationUpdated += locationUpdated; states.ZoneStatusChanged += zoneStatusChanged; states.CurrentZoneChanged += currentZoneChanged; mqtt.MessageReceived += messageReceived; // subscriptions require completed connection mqtt.ConnectAsync().Wait(); // OwnTracks topics are build like this: // // [prefix]/[user]/[device] // // see: http://owntracks.org/booklet/guide/topics/ mqtt.Subscribe(TopicPrefixIn + "/+/+"); log.LogInformation("Engine started."); }