Пример #1
0
        static void Main(string[] args)
        {
            SMPPClient client = new SMPPClient();
            SMSC       sms    = new SMSC()
            {
                Host       = "smpp.smsc.ru",
                Port       = 3700,
                SystemId   = "SystemId",
                Password   = "******",
                SourceTon  = 5,
                SourceNpi  = 1,
                AddrTon    = 1,
                AddrNpi    = 1,
                SystemType = ""
            };

            client.AddSMSC(sms);

            if (client.Connect())
            {
                int res = client.SendSms("from", "to", "message");
                Console.WriteLine(res);

                client.Disconnect();
                client.ClearSMSC();
            }

            Console.ReadLine();
        }
Пример #2
0
        public SmsClient()
        {
            smppClient = new SMPPClient();

            smppClient.OnDeliverSm    += new DeliverSmEventHandler(onDeliverSm);
            smppClient.OnSubmitSmResp += new SubmitSmRespEventHandler(onSubmitSmResp);

            smppClient.OnLog   += new LogEventHandler(onLog);
            smppClient.LogLevel = 0xffff /* LogLevels.LogErrors */;

            LoadConfig();

            smppClient.Connect();
        }
Пример #3
0
        public SmsClient(bool writeLog)
        {
            this.writeLog = writeLog;

            smppClient                 = new SMPPClient();
            smppClient.WriteLog        = writeLog;
            smppClient.OnDeliverSm    += new DeliverSmEventHandler(onDeliverSm);
            smppClient.OnSubmitSmResp += new SubmitSmRespEventHandler(onSubmitSmResp);

            smppClient.OnLog   += new LogEventHandler(onLog);
            smppClient.LogLevel = LogLevels.LogErrors;

            LoadConfig();

            smppClient.Connect();
        }
Пример #4
0
        public void Connect()
        {
            smppClient.Connect();

            onLog(new LogEventArgs(string.Format("{1} Connection state = {0}", smppClient.ConnectionState,
                                                 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture))));
            int cnt = 0;

            while (smppClient.ConnectionState != ConnectionStates.SMPP_BINDED)
            {
                Thread.Sleep(1000);
                if (cnt++ > 120)
                {
                    onLog(new LogEventArgs(string.Format("{0} Connection are timed out", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture))));
                    break;
                }
            }
            onLog(new LogEventArgs(string.Format("{1} Connection state = {0}", smppClient.ConnectionState,
                                                 DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture))));
        }
Пример #5
0
 public void Connect()
 {
     smppClient.Connect();
 }