public void Poll(Uri subscription, ServiceEndPoint endPoint)
        {
            ISecureClient client;

            if (endPoint.IsWebSocketEndpoint)
            {
#if HAS_SERVICE_POINT_MANAGER
                client = new SecureWebSocketClient(endPoint, serverCertificate, logs.ForEndpoint(endPoint.BaseUri), pool);
#else
                throw new NotImplementedException("Web Sockets are not available on this platform");
#endif
            }
            else
            {
                client = new SecureClient(endPoint, serverCertificate, logs.ForEndpoint(endPoint.BaseUri), pool);
            }
            pollingClients.Add(new PollingClient(subscription, client, HandleIncomingRequest));
        }
Beispiel #2
0
        public void Poll(Uri subscription, ServiceEndPoint endPoint, CancellationToken cancellationToken)
        {
            ISecureClient client;
            var           log = logs.ForEndpoint(endPoint.BaseUri);

            if (endPoint.IsWebSocketEndpoint)
            {
#if SUPPORTS_WEB_SOCKET_CLIENT
                client = new SecureWebSocketClient(endPoint, serverCertificate, log, connectionManager);
#else
                throw new NotSupportedException("The netstandard build of this library cannot act as the client in a WebSocket polling setup");
#endif
            }
            else
            {
                client = new SecureClient(endPoint, serverCertificate, log, connectionManager);
            }
            pollingClients.Add(new PollingClient(subscription, client, HandleIncomingRequest, log, cancellationToken));
        }
Beispiel #3
0
        public void Poll(Uri subscription, ServiceEndPoint endPoint)
        {
            var client = new SecureClient(endPoint, serverCertificate, logs.ForEndpoint(endPoint.BaseUri), pool);

            pollingClients.Add(new PollingClient(subscription, client, HandleIncomingRequest));
        }
Beispiel #4
0
        private void InitializePollingClients()
        {
            _log.Info("Initializing Polling Clients...");
            var packages = _packageRepository.GetPackages();

            if (_pollingCollection != null)
            {
                _pollingCollection.Dispose();
                _pollingCollection = null;
            }
            if (_registeredPackagesPoller != null)
            {
                _registeredPackagesPoller.Dispose();
                _registeredPackagesPoller = null;
            }

            _log.InfoFormat("Global Settings are valid: {areSettingsValid}, and we are in {mode} mode.", _globalSettings.HasValidSettings(), _configurationManager.Mode);
            if (_globalSettings.HasValidSettings() && _configurationManager.Mode == ExecutionMode.Production)
            {
                _log.Info("Setting up for discovery of packages from reflector.");

                // We need to have valid settings AND we need to be in production mode to start the polling agent(s)
                _registeredPackagesPoller = _packagesPollerFactory.Invoke();
                _pollingCollection = _pollingCollectionFactory.Invoke();
                _pollingCollection.Add(_registeredPackagesPoller);
            }
            else if (_globalSettings.HasValidSettings())
            {
                _log.Info("Resolving packages from local cache.");
                // Just discover the packages from the hard disk drive's hoarde directory and start 'em up.
                packages.Apply(p =>
                    _eventBus.Publish(new ShellRequestArgs
                    {
                        ActionToTake = ShellAction.Startup,
                        PackageId = p.Id,
                        Version = string.Empty,
                        ConfigurationManager = _dbConfigurationSettingsFactory.Invoke(p.Id)
                    })
                );
            }
            else
            {
                _log.Warn("Did not start polling services, nor could we read from the local store.");
                _log.WarnFormat("Global Settings are valid: {hasValidSettings} | Execution Mode: {executionMode}", _globalSettings.HasValidSettings(), _configurationManager.Mode);
            }
        }