Пример #1
0
        /// <summary>
        /// This method sends a submit_sm packet synchronously over to the peer.
        /// </summary>
        /// <param name="pdu">submit_sm packet</param>
        /// <returns>submit_sm response</returns>
        public submit_sm_resp SubmitSm(submit_sm pdu)
        {
            submit_sm_resp response = null;
            PduSyncronizer sync     = AddWaitingPdu(pdu);

            if (sync != null)
            {
                if (IsBound && SendPdu(pdu))
                {
                    if (sync.WaitForResponse())
                    {
                        response = sync.PduResponse as submit_sm_resp;
                        if (response == null)
                        {
                            response = new submit_sm_resp(pdu.SequenceNumber, sync.PduResponse.Status);
                        }
                    }
                    else
                    {
                        response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RINVEXPIRY);
                    }
                }
                else
                {
                    response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RSUBMITFAIL);
                }
                FindAndRemoveWaitingPdu(pdu.SequenceNumber);
            }
            else
            {
                response = new submit_sm_resp(pdu.SequenceNumber, StatusCodes.ESME_RMSGQFUL);
            }

            return(response);
        }
Пример #2
0
        private void btnSendMessage_Click(object sender, EventArgs e)
        {
            // Confirm all settings
            string sourceNumber    = txtSourceNumber.Text.Trim();
            string rawTargetNumber = txtDestinationNumber.Text.Trim();
            string message         = txtMessage.Text.Trim();

            if ((sourceNumber.Length < 5) || (rawTargetNumber.Length < 10) || (message.Length == 0))
            {
                MessageBox.Show("Either a number is invalid or the message is blank");
                return;
            }
            // Add target address prefix
            string targetNumber = destinationAdrPrefix_ + rawTargetNumber;

            // Disable send until we get a reply from the SMSC for the current nessage
            btnSendMessage.Enabled = false;

            submit_sm submitPdu = new submit_sm();

            if (!string.IsNullOrEmpty(submitServiceType_))
            {
                submitPdu.ServiceType = submitServiceType_;
            }
            submitPdu.SourceAddress      = new address(TypeOfNumber.NATIONAL, NumericPlanIndicator.E164, sourceNumber);
            submitPdu.DestinationAddress = new address(TypeOfNumber.NATIONAL, NumericPlanIndicator.E164, targetNumber);
            submitPdu.RegisteredDelivery = new registered_delivery(DeliveryReceiptType.FINAL_DELIVERY_RECEIPT, AcknowledgementType.DELIVERY_USER_ACK_REQUEST, true);
            submitPdu.Message            = message;
            smppSession_.BeginSubmitSm(submitPdu, new AsyncCallback(SubmitSmCallback));

            // Add the message to the sent listview using the message sequence # for tracking
            AddNewMessage("Pending", targetNumber, message, "n/a", "n/a", submitPdu.SequenceNumber);
        }
Пример #3
0
 public SmsMessage(SmppSession sess, submit_sm pdu, string msgId, DeliveryReceiptType responseRequested)
 {
     Session         = sess;
     PDU             = pdu;
     MessageId       = msgId;
     deliveryReceipt = responseRequested;
 }
Пример #4
0
        /// <summary>
        /// This processes the submit_sm event.
        /// </summary>
        /// <param name="pdu">Protocol Data Unit</param>
        public override void Process(submit_sm pdu)
        {
            SmppEventArgs ea = new SmppEventArgs(session_, pdu, new submit_sm_resp(pdu.SequenceNumber));

            if (!session_.FireEvent(EventType.SubmitSm, ea))
            {
                ea.ResponsePDU.Status = StatusCodes.ESME_RSUBMITFAIL;
            }
            session_.SendPdu(ea.ResponsePDU);
        }
Пример #5
0
        private static void OnSessionBound(object sender, SmppEventArgs args)
        {
            // Session is now bound
            Console.WriteLine("Session is successfully bound to the SMSC");
            // Try sending a single message
            submit_sm submitPdu = new submit_sm();

            submitPdu.SourceAddress      = new address(TypeOfNumber.NATIONAL, NumericPlanIndicator.E164, "9727321655");
            submitPdu.DestinationAddress = new address(TypeOfNumber.NATIONAL, NumericPlanIndicator.E164, "9724151634");
            submitPdu.RegisteredDelivery = new registered_delivery(DeliveryReceiptType.FINAL_DELIVERY_RECEIPT, AcknowledgementType.DELIVERY_USER_ACK_REQUEST, true);
            mBloxOperatorId operatorId = new mBloxOperatorId("12345");

            submitPdu.AddVendorSpecificElements(operatorId);
            submitPdu.Message = "This is a test";
//            TlvParameter test = submitPdu.GetOptionalElement(operatorId.Tag);
            _smppSession.BeginSubmitSm(submitPdu, new AsyncCallback(SubmitSmCallback));
        }
Пример #6
0
        private void OnSubmitSm(object sender, SmppEventArgs ea)
        {
            submit_sm req = (submit_sm)ea.PDU;

            AddLogText(StatusCode.Normal, string.Format("SendSms: {0}", req.Message));

            submit_sm_resp resp = (submit_sm_resp)ea.ResponsePDU;

            resp.MessageID = Interlocked.Increment(ref nxtMid_).ToString();

            // Create our tracking message and insert it into the list.
            SmsMessage message = new SmsMessage(ea.Session, req, resp.MessageID, req.RegisteredDelivery.DeliveryReceipt);

            new MessageListViewItem(lvMessages, message);
            arrMessages.Add(message);

            // If we need a delivery receipt, then generate a callback to provide it.
            if (respType_ != MessageResponse.Manual_Response)
            {
                new System.Threading.Timer(new TimerCallback(SendAck), message, randGen_.Next(10000), Timeout.Infinite);
            }
        }
Пример #7
0
        /// <summary>
        /// This method invokes the SubmitSm method asynchronously
        /// </summary>
        /// <param name="pdu">submit_sm PDU to send</param>
        /// <param name="callback">Asynch callback</param>
        /// <returns>IAsyncResult interface for monitoring</returns>
        public IAsyncResult BeginSubmitSm(submit_sm pdu, AsyncCallback callback)
        {
            AsynchCall acr = new AsynchCall(callback, this);

            return(acr.BeginInvoke(new SubmitSmDelegate(SubmitSm), new object[] { pdu }));
        }
Пример #8
0
 /// <summary>
 /// This processes the submit_sm PDU
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public override void Process(submit_sm pdu)
 {
     tx_.Process(pdu);
 }
Пример #9
0
 /// <summary>
 /// This processes the submit_sm PDU
 /// </summary>
 /// <param name="pdu">Protocol Data Unit being processed</param>
 public virtual void Process(submit_sm pdu)
 {
     throw new InvalidSmppStateException("Session is not in the proper state for a submit_sm operation.");
 }