示例#1
0
        private async void ConnectedToServer(HostRecordsEvents.HostRecordApplied connected)
        {
            var devices = _deviceProviders.SelectMany(q => q.AvailableDevices).ToList();
            var kinds   = devices.Select(q => q.Kind).GroupBy(q => q).Select(q => q.First()).ToList();

            foreach (var kind in kinds)
            {
                if (!CoreKinds.Kind.TryConvertToDocument(kind, out var document))
                {
                    //  todo: log failure
                    continue;
                }

                await _apiServer.Apply(document);
            }

            foreach (var device in devices)
            {
                if (!device.Kind.TryConvertToDocument(device, out var document))
                {
                    //  todo: log failure
                    continue;
                }

                await _apiServer.Apply(document);
            }
        }
示例#2
0
        private async Task ApplyHostConfigOnApiServer()
        {
            try
            {
                await UpdateLocalEndpoint();

                await _apiServer.Apply(_appHost);

                _eventBus.Publish(new HostRecordsEvents.HostRecordApplied(_appHost));
            }
            catch (Exception ex)
            {
                //  todo: keep attempting to notify the API server of the nodes presence?
                //  todo: log exception
            }
        }