Пример #1
0
        public static async Task <bool> SendCmppReportAsync(this SmsServerSession session, CmppMessageReport report)
        {
            var cmppServer = session.Server as CmppSmsServer;


            var serviceId = cmppServer.Configurations.ServiceID;
            var d         = new CmppMessageDeliver()
            {
                SequenceId             = session.SequenceId,
                Id                     = report.Id,
                Format                 = (byte)CmppEncodings.ASCII,
                ReceiverId             = report.ReceiverTerminalId,
                ServiceId              = serviceId,
                DeliveryReportRequired = 1,
                ServiceTerminalId      = serviceId,
                LinkId                 = string.Empty
            };

            d.SetReport(report);
            return(await session.SendAsync(d));
        }
Пример #2
0
        protected override async Task DoNetworkMessageReceived(SmsServerSession session, NetworkMessage message)
        {
            if (message is CmppMessageConnect)
            {
                var m = message as CmppMessageConnect;
                var r = new CmppMessageConnectResponse();
                r.SequenceId        = m.SequenceId;
                r.Version           = 0x30;
                r.AuthenticatorISMG = new byte[16];
                r.Status            = 0;
                await session.SendAsync(r);
            }
            else if (message is CmppMessageSubmit)
            {
                var m = message as CmppMessageSubmit;

                var r = new CmppMessageSubmitResponse();
                r.SequenceId = m.SequenceId;
                r.MessasgeId = this.GetMessageId();
                r.Result     = 0;

                await session.SendAsync(r);

                var time   = DateTime.Now;
                var report = new CmppMessageReport()
                {
                    Id   = r.MessasgeId,
                    Stat = "DELIVRD",
                    ReceiverTerminalId = m.ReceiverTerminalIds[0],
                    CompleteTime       = time.AddMinutes(20).ToString("yyMMddHHmm"),
                    SubmitTime         = time.ToString("yyMMddHHmm"),
                    SmscSequence       = 0,
                };
                var d = new CmppMessageDeliver()
                {
                    SequenceId             = this.SequenceId,
                    Id                     = r.MessasgeId,
                    Format                 = (byte)CmppEncodings.ASCII,
                    ReceiverId             = m.ReceiverTerminalIds[0],
                    ServiceId              = _serviceId,
                    DeliveryReportRequired = 1,//状态报告
                    ServiceTerminalId      = _serviceId,
                    LinkId                 = string.Empty
                };
                d.SetReport(report);
                await session.SendAsync(d);

                lock (this)
                {
                    _submitCount++;
                    var stamp = DateTime.Now;

                    if (_startStamp == DateTime.MinValue)
                    {
                        _startStamp = stamp;
                    }
                    _endStamp = stamp;

                    var tick = (long)(_endStamp - _startStamp).TotalSeconds;
                    if (tick != _reportTick)
                    {
                        _reportTick = tick;
                        Console.WriteLine("{0}: {1}...", _submitCount, stamp.ToLongTimeString());
                    }
                }
            }
            else if (message is CmppMessageActiveTest)
            {
                var m = message as CmppMessageActiveTest;
                var r = new CmppMessageActiveTestResponse();
                r.SequenceId = m.SequenceId;
                await session.SendAsync(r);
            }
        }