/// <summary>
 /// Constructor
 /// </summary>
 /// <param name="relay"></param>
 /// <param name="streamId"></param>
 /// <param name="connectionString"></param>
 public RelayStream(ServiceBusRelay relay, Reference streamId,
                    ConnectionString connectionString)
 {
     _relay           = relay;
     StreamId         = streamId;
     ConnectionString = connectionString;
 }
Esempio n. 2
0
        /// <summary>
        /// Create relay provider
        /// </summary>
        /// <param name="iothub"></param>
        /// <param name="relay"></param>
        /// <returns></returns>
        public static async Task <IProvider> CreateAsync(
            ConnectionString iothub, ConnectionString relay)
        {
            if (relay == null)
            {
                throw new ArgumentException("Must provide relay connection string.");
            }
            var service = await ServiceBusRelay.CreateAsync(relay.Entity ??
                                                            "__Microsoft_Azure_Devices_Proxy_1__", relay).ConfigureAwait(false);

            return(new RelayProvider(iothub, service));
        }
        /// <summary>
        /// Create stream service by accessing the namespace.  If the
        /// connection with the given name does not exist, it is created.
        /// Using the key it creates a token provider to instantiate the
        /// relay service.
        /// </summary>
        /// <param name="name">Name of the listener connection</param>
        /// <param name="connectionString">Relay root connection string</param>
        /// <returns>Stream service instance wrapping name space</returns>
        public static async Task <IStreamService> CreateAsync(string name,
                                                              ConnectionString connectionString)
        {
            var ns  = new ServiceBusNamespace(connectionString);
            var key = await ns.GetConnectionKeyAsync(name).ConfigureAwait(false);

            var relay = new ServiceBusRelay(ns.GetConnectionUri(name),
                                            TokenProvider.CreateSharedAccessSignatureTokenProvider("proxy", key));

            await relay.OpenAsync().ConfigureAwait(false);

            return(relay);
        }
Esempio n. 4
0
        /// <summary>
        /// Create relay provider
        /// </summary>
        /// <param name="iothub"></param>
        /// <param name="relay"></param>
        /// <returns></returns>
        public static async Task <IProvider> CreateAsync(
            string iothub, string relay)
        {
            if (relay == null)
            {
                relay = Environment.GetEnvironmentVariable("_SB_CS");
            }
            if (relay == null)
            {
                throw ProxyEventSource.Log.ArgumentNull("relay");
            }

            var cs      = ConnectionString.Parse(relay);
            var service = await ServiceBusRelay.CreateAsync(cs.Entity ??
                                                            "__Microsoft_Azure_Devices_Proxy_1__", cs).ConfigureAwait(false);

            return(new RelayProvider(iothub, service));
        }
Esempio n. 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="relay"></param>
 /// <param name="streamId"></param>
 /// <param name="encoding"></param>
 /// <param name="connectionString"></param>
 public ServiceBusRelayConnection(ServiceBusRelay relay, Reference streamId,
                                  Reference remoteId, CodecId encoding, ConnectionString connectionString) :
     base(streamId, remoteId, encoding, connectionString)
 {
     _relay = relay;
 }