예제 #1
0
        /// <summary>
        /// Sends a batch of events to device hub
        /// </summary>
        /// <returns>The task containing the event</returns>
        public AsyncTask SendEventBatchAsync(IEnumerable <Message> messages)
        {
#if !WINDOWS_UWP
            if (this.impl == null)
            {
                return(AsyncTask.Run(async() =>
                {
                    await this.EnsureOpenedAsync();

                    await this.impl.SendEventBatchAsync(messages).AsTaskOrAsyncOp();
                }));
            }
            else
            {
#endif
            return(this.impl.SendEventBatchAsync(messages).AsTaskOrAsyncOp());

#if !WINDOWS_UWP
        }
#endif
        }
예제 #2
0
        /// <summary>
        /// Sends an event to device hub
        /// </summary>
        /// <returns>The message containing the event</returns>
        public AsyncTask SendEventAsync(Message message)
        {
#if !WINDOWS_UWP
            if (this.impl == null)
            {
                return(AsyncTask.Run(async() =>
                {
                    await this.EnsureOpenedAsync();

                    await this.impl.SendEventAsync(message);
                }));
            }
            else
            {
#endif
            return(this.impl.SendEventAsync(message).AsTaskOrAsyncOp());

#if !WINDOWS_UWP
        }
#endif
        }
예제 #3
0
        /// <summary>
        /// Receive a message from the device queue with the specified timeout
        /// </summary>
        /// <returns>The receive message or null if there was no message until the specified time has elapsed</returns>
        public AsyncTaskOfMessage ReceiveAsync(TimeSpan timeout)
        {
#if !WINDOWS_UWP
            if (this.impl == null)
            {
                return(AsyncTask.Run(async() =>
                {
                    await this.EnsureOpenedAsync();

                    return await this.impl.ReceiveAsync(timeout);
                }));
            }
            else
            {
#endif
            return(this.impl.ReceiveAsync(timeout).AsTaskOrAsyncOp());

#if !WINDOWS_UWP
        }
#endif
        }
예제 #4
0
        /// <summary>
        /// Deletes a received message from the device queue and indicates to the server that the message could not be processed.
        /// </summary>
        /// <returns>The previously received message</returns>
        public AsyncTask RejectAsync(string lockToken)
        {
#if !WINDOWS_UWP
            if (this.impl == null)
            {
                return(AsyncTask.Run(async() =>
                {
                    await this.EnsureOpenedAsync();

                    await this.impl.RejectAsync(lockToken).AsTaskOrAsyncOp();
                }));
            }
            else
            {
#endif
            return(this.impl.RejectAsync(lockToken).AsTaskOrAsyncOp());

#if !WINDOWS_UWP
        }
#endif
        }
예제 #5
0
        /// <summary>
        /// Puts a received message back onto the device queue
        /// </summary>
        /// <returns>The lock identifier for the previously received message</returns>
        public AsyncTask AbandonAsync(Message message)
        {
#if !WINDOWS_UWP && !PCL
            if (this.impl == null)
            {
                return(AsyncTask.Run(async() =>
                {
                    await this.EnsureOpenedAsync();

                    await this.impl.AbandonAsync(message).AsTaskOrAsyncOp();
                }));
            }
            else
            {
#endif
            return(this.impl.AbandonAsync(message).AsTaskOrAsyncOp());

#if !WINDOWS_UWP && !PCL
        }
#endif
        }