public async Task EmitBatchAsync(IEnumerable <LogEvent> batch)
        {
            if (_service == null)
            {
                _service = _factory();
            }

            var asList = batch.Select(s => ChangeLevel(s)).ToList();

            var serialized = asList.Select(s => Serialize(s)).ToArray();

            _batches.Enqueue(serialized);
            while (_batches.Count > 100)
            {
                _batches.Dequeue();
            }

            if (_service.Connection?.State == HubConnectionState.Connected)
            {
                try
                {
                    while (_batches.Count > 0)
                    {
                        var toSend = _batches.Peek();
                        await _service.Connection.InvokeAsync(nameof(IConnectionHubServer.Logs), new ProtocolLogPayload
                        {
                            Logs = toSend
                        });

                        _batches.Dequeue();
                    }
                }
                catch { }
            }
        }
Esempio n. 2
0
 public RootModel(ILifetimeScope container, IWindowStateManager windowStateManager, HubConnectionService hubConnectionService, MainVpnModel mainVpnModel, IAppResources appResources)
 {
     AppData               = appResources.AppData;
     _container            = container;
     WindowStateManager    = windowStateManager;
     _hubConnectionService = hubConnectionService;
     _mainVpnModel         = mainVpnModel;
 }
Esempio n. 3
0
        public CoreData(IdService environment, IDeltaServiceProvider deltaServiceProvider, HubConnectionService hubConnectionService)
        {
            _idService            = environment;
            _hubConnectionService = hubConnectionService;
            _manager              = Build(deltaServiceProvider);
            _manager.RootChanged += OnRootChanged;

            _syncContext = SynchronizationContext.Current;
        }
Esempio n. 4
0
        public MainModel(RootModel root,
                         MainTargetsModel targets,
                         MainSettingsModel settings,
                         SourcesModel sources,
                         StreamSettingsModel streamSettings,
                         MainStreamerModel streamer,
                         MainIndicatorsModel indicators,
                         MainVpnModel vpn,
                         MainAboutModel about,
                         AudioModel audio,
                         HubConnectionService hubConnectionService,
                         IWindowStateManager windowStateManager,
                         IAppEnvironment environment,
                         CoreData coreData,
                         StateLoggerService stateLoggerService,
                         LocalSettingsService localSettingsService,
                         IUpdateManager updateManager,
                         TransientMessageModel transientMessageModel,
                         IAppResources appResources,
                         SceneEditingModel sceneEditingModel,
                         ResourceService resourceService)
        {
            Root                  = root;
            Targets               = targets;
            Settings              = settings;
            Sources               = sources;
            StreamSettings        = streamSettings;
            Streamer              = streamer;
            Indicators            = indicators;
            Vpn                   = vpn;
            About                 = about;
            Audio                 = audio;
            _hubConnectionService = hubConnectionService;
            _windowStateManager   = windowStateManager;
            _environment          = environment;
            _coreData             = coreData;
            _stateLoggerService   = stateLoggerService;
            _localSettingsService = localSettingsService;
            _updateManager        = updateManager;
            TransientMessage      = transientMessageModel;
            _appResources         = appResources;
            SceneEditing          = sceneEditingModel;
            _resourceService      = resourceService;
            _serverClient         = new ModelClient {
                Filter = new FilterConfigurator(true).Build()
            };
            _coreData.GetManager().Register(_serverClient);
            _serverClient.SerializeAndClearChanges();

            _coreData.Subscriptions.OnChangeForSubscriptions = async() => await ProcessLocalOrRemoteChange();

            _coreData.Subscriptions.OnLocalChange = async() => await ProcessLocalChange();
        }