예제 #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.");
        }