Пример #1
0
        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);
            }
        }
Пример #2
0
        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;
 }
Пример #4
0
        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;
        }
Пример #5
0
 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;
 }
Пример #6
0
        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;
        }
Пример #7
0
        /// <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();
 }
Пример #9
0
 public SteamHub(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager) : base(logService, hubConnectionManager)
 {
 }
Пример #10
0
 public TestHub(ILogServiceFactory factory, IHubConnectionManager hubConnectionManager) : base(factory, hubConnectionManager)
 {
 }
Пример #11
0
 public ReactionHub(IHubConnectionManager connectionManager)
     : base(connectionManager)
 {
 }
Пример #12
0
 public BaseHub(IHubConnectionManager connectionManager)
 {
     ConnectionManager = connectionManager;
 }
Пример #13
0
 public BaseSubscribeHub(IHubConnectionManager connectionManager)
     : base(connectionManager)
 {
 }
Пример #14
0
 private void StartConnectionToHub()
 {
     hubConnectionManager = Container.Resolve <IHubConnectionManager>();
     hubConnectionManager.Start();
 }
Пример #15
0
        /// <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;
        }
Пример #16
0
 public NotificationsHub(IHubConnectionManager userConnectionManager)
 {
     _userConnectionManager = userConnectionManager;
 }
Пример #17
0
 public HubBase(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager)
 {
     _hubConnectionManager = hubConnectionManager;
     _logService           = logService.CreateLogger <HubBase <T> >();
 }
Пример #18
0
 public CoinFlipHub(ILogServiceFactory logService, IHubConnectionManager hubConnectionManager) : base(logService, hubConnectionManager)
 {
 }
Пример #19
0
 private static void SetupNotifications(IHubConnectionManager manager)
 {
     manager.StateChanged += change => Console.WriteLine("State changed to:" + change.NewState);
 }
Пример #20
0
        /// <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);
        }
Пример #21
0
 private static void SetupNotifications(IHubConnectionManager manager)
 {
     manager.StateChanged += change => Console.WriteLine("State changed to:" + change.NewState);
 }
Пример #22
0
        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();
        }
Пример #23
0
 public HubConnections(WebsocketWrapper websocketWrapper, Type type, IHubConnectionManager hubConnectionManager)
 {
     _websocketWrapper     = websocketWrapper;
     _type                 = type;
     _hubConnectionManager = hubConnectionManager;
 }