public static async Task UnregisterHubClientAsync(IHubClient client)
 {
     if (_hubClientSet.Remove(client))
     {
         await client.DisconnectHubAsync();
     }
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QueueApiClient"/> class.
 /// </summary>
 /// <param name="apiContract">The api contract.</param>
 /// <param name="hubClient">The hub client.</param>
 /// <param name="blobCache">The cache.</param>
 /// <param name="logger">The logger.</param>
 public QueueApiClient(IQueueApiContract apiContract, IHubClient <QueuedStoreDto> hubClient, IBlobCache blobCache, ILogManager logger)
 {
     _apiContract = apiContract;
     _hubClient   = hubClient;
     BlobCache    = blobCache;
     _logger      = logger.GetLogger(GetType());
 }
        public JobProcessor(JobSpawner jobSpawner, ResourceAdjuster resourceAdjuster, IHubClient hubClient)
        {
            _jobSpawner = jobSpawner;
            _resourceAdjuster = resourceAdjuster;
            _hubClient = hubClient;

            _runningJobs = _runningJobs = new List<ResourceJob>();
        }
        public SettingsProcessor(Logger logger, IHubClient hubClient, int defaultSendIntervalSeconds, CancellationToken shutdownToken)
        {
            _logger    = logger;
            _hubClient = hubClient;
            _defaultSendIntervalSeconds = defaultSendIntervalSeconds;
            _shutdownToken = shutdownToken;

            _monitoredSettingsDataQueue = new BlockingCollection <MessageData>(MonitoredSettingsQueueCapacity);
        }
        public static bool RegisterHubClient(IHubClient client)
        {
            bool result = _hubClientSet.Add(client);

            if (result && (_channel != null))
            {
                client.ConnectHub(_channel);
            }
            return(result);
        }
Example #6
0
        private void Reinitialize()
        {
            _hubClient?.Dispose();
            _hubClient = _hubClientFactory.Create(_commandEndpointId);

            foreach (dynamic adapter in _adapters)
            {
                _hubClient.ListenFor(adapter);
            }
        }
        public void Setup()
        {
            _subscription = new Subscription();

            _proxyMock = new Mock <IHubProxy>();
            _proxyMock.Setup(m => m.Subscribe(It.IsAny <string>())).Returns(_subscription);
            _connectionMock = new Mock <IConnection>();
            _connectionMock.Setup(m => m.State).Returns(ConnectionState.Connected);

            _subject = new HubClient <ISampleCalls, ISampleEvents>(_proxyMock.Object, _connectionMock.Object);
        }
Example #8
0
 public TasksMessagingService(
     IEventConnectionContext context,
     ITaskEventAccessor accessor,
     IHubClient <TasksHub> tasksHubClient,
     ITasksHubUsersStorage storage)
 {
     _context        = context;
     _accessor       = accessor;
     _tasksHubClient = tasksHubClient;
     _storage        = storage;
 }
Example #9
0
        public IoTCEventsProcessor(ILogger logger, IHubClient hubClient, uint hubMessageSize, uint hubMessageSizeMax, int timeout, CancellationToken shutdownToken)
        {
            _logger                      = logger;
            _hubClient                   = hubClient;
            _hubMessageSize              = hubMessageSize;
            _hubMessageSizeMax           = hubMessageSizeMax;
            _timeout                     = timeout;
            _shutdownToken               = shutdownToken;
            _monitoredIoTcEventDataQueue = new BlockingCollection <MessageData>(MonitoredSettingsIoTcEventCapacity);

            Initialize();
        }
Example #10
0
        public void Setup()
        {
            _subscription = new Subscription();

            _proxyMock = new Mock <IHubProxy>();
            _proxyMock.Setup(m => m.Subscribe(It.IsAny <string>())).Returns(_subscription);

            _timeoutValue   = TimeSpan.FromSeconds(0.5);
            _connectionMock = new Mock <IConnection>();
            _connectionMock.Setup(m => m.TotalTransportConnectTimeout).Returns(_timeoutValue);

            _subject = new HubClient <ISampleCalls, ISampleEvents>(_proxyMock.Object, _connectionMock.Object);
        }
Example #11
0
        /// <summary>
        /// Ctor for the class.
        /// </summary>
        public IotEdgeHubCommunication()
        {
            // connect to IoT Edge hub
            Logger.Information($"Create module client using '{HubProtocol}' for communication.");
            IHubClient hubClient = HubClient.CreateModuleClientFromEnvironment(HubProtocol);

            if (!InitHubCommunicationAsync(hubClient).Result)
            {
                string errorMessage = $"Cannot create module client. Exiting...";
                Logger.Fatal(errorMessage);
                throw new Exception(errorMessage);
            }
        }
        /// <summary>
        /// Ctor for the class.
        /// </summary>
        public IotEdgeHubCommunication(bool registerMethodHandlers, bool listenMessages)
        {
            // connect to IoT Edge hub
            Logger.Information($"Create module client using '{HubProtocol}' for communication.");
            _hubClient = HubClient.CreateModuleClientFromEnvironment(HubProtocol, Logger);

            if (!InitHubCommunicationAsync(_hubClient, registerMethodHandlers, listenMessages).Result)
            {
                string errorMessage = $"Cannot create module client. Exiting...";
                Logger.Fatal(errorMessage);
                throw new Exception(errorMessage);
            }
        }
Example #13
0
        bool disposedValue; // To detect redundant calls

        /// <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 (!disposedValue)
            {
                if (disposing)
                {
                    configUpdateTimer.Stop();
                    configUpdateTimer.Elapsed -= ConfigUpdateTimer_Elapsed;
                    configUpdateTimer.Dispose();
                }

                hub = null;

                disposedValue = true;
            }
        }
Example #14
0
 public MotionManager(IHubClient hubClient)
 {
     this.hubClient        = hubClient;
     measureTimer.Elapsed += MeasureTimer_Elapsed;
     measureTimer.Start();
 }
Example #15
0
 public TemperatureManager(IHubClient hubClient)
 {
     this.hubClient        = hubClient;
     measureTimer.Elapsed += MeasureTimer_Elapsed;
     measureTimer.Start();
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoomManager"/> class.
 /// </summary>
 /// <param name="hub">The hub that is used to send updates that may occur in any channels of the rooms.</param>
 public RoomManager(IHubClient hub)
 {
     this.hub = hub;
 }
Example #17
0
        bool disposedValue; // To detect redundant calls

        /// <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 (!disposedValue)
            {
                if (disposing)
                {
                    configUpdateTimer.Stop();
                    configUpdateTimer.Elapsed -= ConfigUpdateTimer_Elapsed;
                    configUpdateTimer.Dispose();
                }

                hub = null;

                disposedValue = true;
            }
        }
 private EventHubSink(IHubClient client)
 {
     _client = client;
     Shape   = new SinkShape <IEnumerable <EventData> >(In);
 }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RoomManager"/> class.
 /// </summary>
 /// <param name="hub">The hub that is used to send updates that may occur in any channels of the rooms.</param>
 public RoomManager(IHubClient hub)
 {
     this.hub = hub;
 }