Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="deviceName">Device name</param>
        /// <param name="deviceId">Device ID</param>
        /// <param name="connectionString">Connection string to Service Bus namespace</param>
        /// <param name="eventhubentity">Event Hub entity name</param>
        public IoTClientBase(string deviceName, string deviceId, string connectionString, string eventhubentity)
        {
            this.DeviceName = deviceName;
            this.DeviceId = deviceId;
            this.queue = new Queue<EventData>();
            this.queueEvent = new AutoResetEvent(false);

            ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder(connectionString);
            builder.TransportType = TransportType.Amqp;
            this.factory = MessagingFactory.CreateFromConnectionString(builder.ToString());

            this.client = this.factory.CreateEventHubClient(eventhubentity);
        }
 public static string CreateUsingSharedAccessSignature(Uri endpoint, string entityPath, string publisher, string sharedAccessSignature)
 {
     ServiceBusConnectionStringBuilder builder = new ServiceBusConnectionStringBuilder
     {
         Endpoint = endpoint,
         EntityPath = entityPath,
         Publisher = publisher,
         SharedAccessSignature = sharedAccessSignature
     };
     return builder.ToString();
 }