Ejemplo n.º 1
0
        public SubscriptionChangeHandler(
            ICloud2DeviceMessageHandler cloud2DeviceMessageHandler,
            IModuleToModuleMessageHandler moduleToModuleMessageHandler,
            IDirectMethodHandler directMethodHandler,
            ITwinHandler twinHandler,
            IConnectionRegistry connectionRegistry,
            IIdentityProvider identityProvider)
        {
            Preconditions.CheckNotNull(cloud2DeviceMessageHandler);
            Preconditions.CheckNotNull(moduleToModuleMessageHandler);
            Preconditions.CheckNotNull(directMethodHandler);
            Preconditions.CheckNotNull(twinHandler);

            this.connectionRegistry = Preconditions.CheckNotNull(connectionRegistry);
            this.identityProvider   = Preconditions.CheckNotNull(identityProvider);

            this.subscriptionPatterns = new List <SubscriptionPattern>();
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(cloud2DeviceMessageHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(moduleToModuleMessageHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(directMethodHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(twinHandler.WatchedSubscriptions));

            // Later we need all possible subscriptions in use, but don't want to recalculate every time, so
            // store it now.
            this.allSubscriptions = this.subscriptionPatterns.Select(s => s.Subscription).Distinct().ToArray();
        }
Ejemplo n.º 2
0
        public DeviceProxy(
            IIdentity identity,
            bool isDirectClient,
            IConnectionRegistry connectionRegistry,
            ITwinHandler twinHandler,
            IModuleToModuleMessageHandler moduleToModuleMessageHandler,
            ICloud2DeviceMessageHandler cloud2DeviceMessageHandler,
            IDirectMethodHandler directMethodHandler)
        {
            this.Identity                     = Preconditions.CheckNotNull(identity);
            this.connectionRegistry           = Preconditions.CheckNotNull(connectionRegistry);
            this.twinHandler                  = Preconditions.CheckNotNull(twinHandler);
            this.moduleToModuleMessageHandler = Preconditions.CheckNotNull(moduleToModuleMessageHandler);
            this.cloud2DeviceMessageHandler   = Preconditions.CheckNotNull(cloud2DeviceMessageHandler);
            this.directMethodHandler          = Preconditions.CheckNotNull(directMethodHandler);
            this.isActive                     = new AtomicBoolean(true);
            this.IsDirectClient               = isDirectClient;

            // when a child edge device connects, it uses $edgeHub identity.
            // Although it is a direct client, it uses the indirect topics
            if (identity is ModuleIdentity moduleIdentity)
            {
                if (string.Equals(moduleIdentity.ModuleId, Constants.EdgeHubModuleId))
                {
                    this.IsDirectClient = false;
                }
            }

            Events.Created(this.Identity);
        }
Ejemplo n.º 3
0
        public DeviceProxy(
            IIdentity identity,
            ITwinHandler twinHandler,
            IModuleToModuleMessageHandler moduleToModuleMessageHandler,
            ICloud2DeviceMessageHandler cloud2DeviceMessageHandler,
            IDirectMethodHandler directMethodHandler)
        {
            this.Identity    = Preconditions.CheckNotNull(identity);
            this.twinHandler = Preconditions.CheckNotNull(twinHandler);
            this.moduleToModuleMessageHandler = Preconditions.CheckNotNull(moduleToModuleMessageHandler);
            this.cloud2DeviceMessageHandler   = Preconditions.CheckNotNull(cloud2DeviceMessageHandler);
            this.directMethodHandler          = Preconditions.CheckNotNull(directMethodHandler);
            this.isActive = new AtomicBoolean(true);

            Events.Created(this.Identity);
        }
Ejemplo n.º 4
0
        public SubscriptionChangeHandler(
            ICloud2DeviceMessageHandler cloud2DeviceMessageHandler,
            IModuleToModuleMessageHandler moduleToModuleMessageHandler,
            IDirectMethodHandler directMethodHandler,
            ITwinHandler twinHandler,
            IConnectionRegistry connectionRegistry,
            IIdentityProvider identityProvider)
        {
            Preconditions.CheckNotNull(cloud2DeviceMessageHandler);
            Preconditions.CheckNotNull(moduleToModuleMessageHandler);
            Preconditions.CheckNotNull(directMethodHandler);
            Preconditions.CheckNotNull(twinHandler);

            this.connectionRegistry = Preconditions.CheckNotNull(connectionRegistry);
            this.identityProvider   = Preconditions.CheckNotNull(identityProvider);

            this.subscriptionPatterns = new List <SubscriptionPattern>();
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(cloud2DeviceMessageHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(moduleToModuleMessageHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(directMethodHandler.WatchedSubscriptions));
            this.subscriptionPatterns.AddRange(Preconditions.CheckNotNull(twinHandler.WatchedSubscriptions));
        }