コード例 #1
0
        public async Task <Try <ICloudConnection> > Connect(IIdentity identity, Action <string, CloudConnectionStatus> connectionStatusChangedHandler)
        {
            if (!await this.IsConnected())
            {
                return(new Try <ICloudConnection>(new Exception("Bridge is not connected upstream")));
            }

            var cloudProxy = new BrokeredCloudProxy(identity, this.cloudProxyDispatcher, connectionStatusChangedHandler);

            return(new Try <ICloudConnection>(new BrokeredCloudConnection(identity, cloudProxy)));
        }
コード例 #2
0
        public async Task <Try <ICloudConnection> > Connect(IIdentity identity, Action <string, CloudConnectionStatus> connectionStatusChangedHandler)
        {
            if (!await this.IsConnected())
            {
                return(Try <ICloudConnection> .Failure(new IotHubException("Bridge is not connected upstream")));
            }

            try
            {
                // TODO: Check disconnect reason and refresh identity when MQTT5 is supported
                // The identity is not refreshed for now because there is no way to detect when the connection was dropped from upstream because unauthorized
                await this.deviceScopeIdentitiesCache.VerifyServiceIdentityAuthChainState(identity.Id, isNestedEdgeEnabled : true, refreshCachedIdentity : false);
            }
            catch (DeviceInvalidStateException ex)
            {
                return(Try <ICloudConnection> .Failure(ex));
            }

            var cloudProxy = new BrokeredCloudProxy(identity, this.cloudProxyDispatcher, connectionStatusChangedHandler);
            await cloudProxy.OpenAsync();

            return(new Try <ICloudConnection>(new BrokeredCloudConnection(identity, cloudProxy)));
        }
コード例 #3
0
 public BrokeredCloudConnection(BrokeredCloudProxy cloudProxy)
 {
     this.IsActive   = true;
     this.CloudProxy = Option.Some(cloudProxy as ICloudProxy);
 }
コード例 #4
0
        public Task <Try <ICloudConnection> > Connect(IIdentity identity, Action <string, CloudConnectionStatus> connectionStatusChangedHandler)
        {
            var cloudProxy = new BrokeredCloudProxy(identity, this.cloudProxyDispatcher, connectionStatusChangedHandler);

            return(Task.FromResult(new Try <ICloudConnection>(new BrokeredCloudConnection(cloudProxy))));
        }