Exemple #1
0
        public async Task <bool> SendSmsAsync(string[] receivers, string content, object state = null)
        {
            await this.EnsureConnected();

            var envolope = new SmsMessageEnvolope();

            await this.DoSendSmsAsync(receivers, content, envolope);

            var m = envolope.Request;

            if (m == null)
            {
                return(false);
            }

            envolope.SendTimeStamp = DateTime.Now;
            envolope.State         = state;

            var records = this.MessageRecords;

            records.TryAdd(envolope.SequenceId, envolope);

            while (!this.IsCancellationRequested && records.Count > this.QueueWindowSize)
            {
                await Task.Delay(50);
            }
            return(await this.SendAsync(m));
        }
Exemple #2
0
 protected void RaiseResponseReceived(SmsMessageEnvolope envolope)
 {
     try
     {
         var evt = this.SmsResponseReceived;
         if (evt != null)
         {
             evt(this, new SmsResponseEventArgs(envolope));
         }
     }
     catch { }
 }
Exemple #3
0
        protected virtual async Task <bool> DoSendSmsAsync(string[] receivers, string content, SmsMessageEnvolope envolope)
        {
            await Task.Delay(0);

            return(true);
        }
 public SmsResponseEventArgs(SmsMessageEnvolope envolope)
 {
     this.Envolope = envolope;
 }