Exemplo n.º 1
0
        public void RegisterSMSC(SMSCServerHandler handler)
        {
            this.smscHandler = handler;
            if (submitTimer != null)
            {
                submitTimer.Stop();
            }
            submitTimer          = new System.Timers.Timer(1000);
            submitTimer.Elapsed += (sender, e) =>
            {
                submitLocker.EnterWriteLock();

                if (submitQueue.Count > 0)
                {
                    var deliver = submitQueue.Dequeue();
                    var client  = handler.GetMTClient(deliver.UserNumber);

                    //若手机客户端在线则转发,不在线则丢弃等待下次上线再转发
                    if (client != null)
                    {
                        client.Socket.Send(deliver.GetBytes());
                    }
                }

                submitLocker.ExitWriteLock();
            };

            submitTimer.Start();
        }
Exemplo n.º 2
0
 public void UnRegisterSMSC()
 {
     if (smscHandler != null)
     {
         try
         {
             submitTimer.Stop();
             submitQueue.Clear();
             smscHandler = null;
         }
         catch
         {
             throw;
         }
     }
 }