示例#1
0
        private async Task ConnectAsync()
        {
            _logger.LogInformation("Connecting to broker with configuration {@Configuration}", _serverConfig);

            await _client.ConnectAsync(_serverConfig);

            _logger.LogInformation("Connected succesfully");

            _client.MessageReceivedAsync += HandleMessageAsync;
        }
示例#2
0
文件: Engine.cs 项目: akeil/OwnZone
        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.");
        }