static void Main(string[] args) { string CLIENT_HUB = "ClientHub"; string WORKING_URL = "http://localhost:6790"; _manager = HubConnectionManager.GetHubConnectionManager(WORKING_URL); Console.WriteLine("Attmepting to connect to SignalR endpoint..."); IHubProxy hubProxy = _manager.CreateHubProxy(CLIENT_HUB); SetupNotifications(_manager); _manager.Initialize().ContinueWith(task => Console.WriteLine(task.IsFaulted ? "There was an error opening the connection." : "Connected.")).Wait(); while (true) { if (_manager.State == ConnectionState.Connected) { try { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(hubProxy.Invoke<string>("Greetings", "User").Result); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Connected via " + _manager.ConnectionType.Name); } catch { } } //Chill Thread.Sleep(5000); } }
static void Main(string[] args) { string CLIENT_HUB = "ClientHub"; string WORKING_URL = "http://localhost:6790"; _manager = HubConnectionManager.GetHubConnectionManager(WORKING_URL); Console.WriteLine("Attmepting to connect to SignalR endpoint..."); IHubProxy hubProxy = _manager.CreateHubProxy(CLIENT_HUB); SetupNotifications(_manager); _manager.Initialize().ContinueWith(task => Console.WriteLine(task.IsFaulted ? "There was an error opening the connection." : "Connected.")).Wait(); while (true) { if (_manager.State == ConnectionState.Connected) { try { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(hubProxy.Invoke <string>("Greetings", "User").Result); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Connected via " + _manager.ConnectionType.Name); } catch { } } //Chill Thread.Sleep(5000); } }
public SendAcknowledgmentCommandHandler( IHubConnectionManager hubConnectionManager, IAccessTokenService accessTokenService) { this.hubConnectionManager = hubConnectionManager; this.accessTokenService = accessTokenService; }
public PaysController(Web.Services.ISubscribesService subscribesService, IHubContext <NotificationsHub> notificationHubContext, IHubConnectionManager userConnectionManager, INoticesService noticesService, IMailService mailService, IWebHostEnvironment environment, IOptions <AppSettings> appSettings, IAppLogger appLogger) { _subscribesService = subscribesService; _notificationHubContext = notificationHubContext; _userConnectionManager = userConnectionManager; _noticesService = noticesService; _mailService = mailService; _environment = environment; _appSettings = appSettings.Value; _logger = appLogger; }
public WebSocketSenderFactory( IHubContext <SteamHub> steamHubContext, IHubContext <MatchHub> matchHubContext, IHubContext <TestHub> adminHubContext, IHubContext <BetHub> betHubContext, IHubContext <ChatHub> chatHubContext, IHubContext <InfoHub> infoHubContext, IHubContext <TicketHub> ticketHubContext, IHubContext <CoinFlipHub> coinFlipHubContext, IHubConnectionManager hubConnectionManager ) { _steamHubContext = steamHubContext; _matchHubContext = matchHubContext; _adminHubContext = adminHubContext; _betHubContext = betHubContext; _chatHubContext = chatHubContext; _infoHubContext = infoHubContext; _ticketHubContext = ticketHubContext; _coinFlipHubContext = coinFlipHubContext; _hubConnectionManager = hubConnectionManager; }
public ATestsController(IWebHostEnvironment environment, IOptions <AppSettings> appSettings, IAppLogger appLogger, IHubContext <NotificationsHub> notificationHubContext, IHubConnectionManager userConnectionManager, IDataService dataService, ICloudStorageService cloudStorageService, IOptions <AdminSettings> adminSettings, INoticesService noticesService, IMailService mailService, Web.Services.ISubscribesService subscribesService, ITestsService testsService) { _environment = environment; _appSettings = appSettings.Value; _logger = appLogger; _dataService = dataService; _cloudStorageService = cloudStorageService; _notificationHubContext = notificationHubContext; _userConnectionManager = userConnectionManager; _noticesService = noticesService; _mailService = mailService; _subscribesService = subscribesService; _adminSettings = adminSettings.Value; _testsService = testsService; }
/// <summary> /// Stops all services managed by this. /// </summary> /// <returns></returns> public bool Stop() { _log.Info("Drey.Runtime is shutting down."); if (_pushServices.Any()) { _log.Info("Shutting down push services."); Task.WaitAll(_pushServices.Select(x => x.Stop()).ToArray()); _log.Info("All services should be shut down."); } _runtimeHubProxy = null; if (_hubConnectionManager != null) { _log.Info("Disposing the connection manager."); _hubConnectionManager.Dispose(); _hubConnectionManager = null; } return true; }
private void StartConnectionToHub() { hubConnectionManager = Container.Resolve<IHubConnectionManager>(); hubConnectionManager.Start(); }
public SteamHub(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager) : base(logService, hubConnectionManager) { }
public TestHub(ILogServiceFactory factory, IHubConnectionManager hubConnectionManager) : base(factory, hubConnectionManager) { }
public ReactionHub(IHubConnectionManager connectionManager) : base(connectionManager) { }
public BaseHub(IHubConnectionManager connectionManager) { ConnectionManager = connectionManager; }
public BaseSubscribeHub(IHubConnectionManager connectionManager) : base(connectionManager) { }
private void StartConnectionToHub() { hubConnectionManager = Container.Resolve <IHubConnectionManager>(); hubConnectionManager.Start(); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!disposing || _disposed) { return; } if (_pollingCollection != null) { _pollingCollection.Dispose(); _pollingCollection = null; } if (_registeredPackagesPoller != null) { _registeredPackagesPoller.Dispose(); _registeredPackagesPoller = null; } if (_runtimeHubProxy != null) { _runtimeHubProxy = null; } if (_hubConnectionManager != null) { _hubConnectionManager.Dispose(); _hubConnectionManager = null; } _disposed = true; }
public NotificationsHub(IHubConnectionManager userConnectionManager) { _userConnectionManager = userConnectionManager; }
public HubBase(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager) { _hubConnectionManager = hubConnectionManager; _logService = logService.CreateLogger <HubBase <T> >(); }
public CoinFlipHub(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager) : base(logService, hubConnectionManager) { }
private static void SetupNotifications(IHubConnectionManager manager) { manager.StateChanged += change => Console.WriteLine("State changed to:" + change.NewState); }
/// <summary> /// Starts the Health Service. /// </summary> /// <param name="hubConnectionManager">The hub connection manager.</param> /// <param name="runtimeHubProxy">The runtime hub proxy.</param> public Task Start(IHubConnectionManager hubConnectionManager, IHubProxy runtimeHubProxy) { _log.Info("Starting 'Report Health Service'."); _hubConnectionManager = hubConnectionManager; _runtimeHubProxy = runtimeHubProxy; try { DiscoverDotNetFrameworks(); } catch (SecurityException secEx) { if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) { _frameworkInfo.NetFxVersions = new[] { new DomainModel.FrameworkVersion { BuildVersion = Environment.Version.ToString(), CommonVersion = string.Format("Mono on {0}", Environment.OSVersion.Platform), ServicePack = string.Empty } }; } else { _log.WarnException("Security exception while reading registry", secEx); } } catch (NullReferenceException nrEx) { if (Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix) { _frameworkInfo.NetFxVersions = new[] { new DomainModel.FrameworkVersion { BuildVersion = Environment.Version.ToString(), CommonVersion = string.Format("Mono on {0}", Environment.OSVersion.Platform), ServicePack = string.Empty } }; } else { _log.WarnException("Null Reference exception while reading from registry", nrEx); } } try { _registeredDbFactories = DbProviderFactories.GetFactoryClasses().Select().Select(x => new DomainModel.RegisteredDbProviderFactory { Name = x["Name"].ToString(), Description = x["Description"].ToString(), InvariantName = x["InvariantName"].ToString(), AssemblyQualifiedName = x["AssemblyQualifiedName"].ToString() }).ToArray(); } catch (NullReferenceException) { _registeredDbFactories = new DomainModel.RegisteredDbProviderFactory[0]; } _log.Info("Starting 'Report Health Info' trigger."); _worker = new Task(Report); _worker.Start(); return Task.FromResult((object)null); }
private Task Connect() { if (!_globalSettings.HasValidSettings()) { var tsc = new TaskCompletionSource<object>(); tsc.SetException(new Exception("System has not been setup")); return tsc.Task; }; var brokerUrl = _globalSettings.GetServerHostname(); _log.Debug("Connecting to runtime hub."); _hubConnectionManager = HubConnectionManager.GetHubConnectionManager(brokerUrl.CurrentHostname); _hubConnectionManager.UseClientCertificate(_globalSettings.GetCertificate()); _log.Debug("Creating runtime hub proxy and assigning to services."); _runtimeHubProxy = _hubConnectionManager.CreateHubProxy("Runtime"); _log.DebugFormat("# of Remote invoked services registered: {count}", _remoteInvokedServices.Count()); _remoteInvokedServices.Apply(x => x.SubscribeToEvents(_runtimeHubProxy)); _log.DebugFormat("# of push services registered: {count}", _pushServices.Count()); _pushServices.Apply(x => x.Start(_hubConnectionManager, _runtimeHubProxy)); _log.Debug("Establishing connection to runtime hub."); _hubConnectionManager.StateChanged += change => { switch (change.NewState) { case ConnectionState.Connecting: _log.InfoFormat("Attempting to connect to {url}.", brokerUrl.CurrentHostname); break; case ConnectionState.Connected: _log.InfoFormat("Connection established with {url}.", brokerUrl.CurrentHostname); break; case ConnectionState.Reconnecting: _log.InfoFormat("Lost connection with {url}. Attempting to reconnect.", brokerUrl.CurrentHostname); break; case ConnectionState.Disconnected: _log.InfoFormat("Disconnected from {url}", brokerUrl.CurrentHostname); break; } }; return _hubConnectionManager.Initialize(); }
public HubConnections(WebsocketWrapper websocketWrapper, Type type, IHubConnectionManager hubConnectionManager) { _websocketWrapper = websocketWrapper; _type = type; _hubConnectionManager = hubConnectionManager; }