SafeDispatch/SDRgateway/SMSmanager.cs

59 lines
1.9 KiB
C#
Raw Permalink Normal View History

2024-02-22 16:43:59 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace SDRgateway
{
class SMSmanager
{
private static System.Threading.Timer tCheckMail;
private Thread t_CheckSMS_out;
private SDR sdr;
private Config config;
public SMSmanager(SDR _sdr, Config config)
{
sdr = _sdr;
this.config = config;
//tCheckSMSqueue = new System.Threading.Timer(CheckQueue, null, new TimeSpan(0, 0, 5), new TimeSpan(0, 0, 5));
t_CheckSMS_out = new Thread(new ThreadStart(CheckQueue));
t_CheckSMS_out.IsBackground = true;
t_CheckSMS_out.Start();
}
private void CheckQueue()
{
while (true)
{
try
{
msgCell cell = Program.smsOutQueue.GetItem(100);
while (cell != null)
{
// if CallOut option is selected
if (config.SDR_CallOut == 1)
sdr.SendCallOutMessage(Int32.Parse(cell.IMEI),
LIPSDR.Stds_CallOutAlertPDU_sdsEncoder(LIPSDR.callOutNumber++, LIPSDR.CallOutFunction.Clear, 3, 0x00, cell.sms, LIPSDR.TGctrl.TGControlNotUsed));
else
sdr.SEND_SMS(uint.Parse(cell.IMEI), cell.sms);
Thread.Sleep(100);
cell = Program.smsOutQueue.GetItem(100);
}
}
catch (Exception ex)
{
Console.WriteLine("Error in SMSmanager/CheckQueue \n" + ex.ToString());
Thread.Sleep(1000);
}
Thread.Sleep(1000);
}
}
}
}