Exemple #1
0
        /// <summary>
        /// Sends message to a remote SMMP server
        /// </summary>
        /// <param name="message">A message to send</param>
        /// <param name="timeOut">A value in miliseconds after which the send operation times out</param>
        public void SendMessage(ShortMessage message, int timeOut)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            //Check if connection is open
            if (vState != SmppConnectionState.Connected)
            {
                throw new SmppClientException("Sending message operation failed because the SmppClient is not connected");
            }

            string messageId = null;

            foreach (SendSmPDU pdu in message.GetMessagePDUs(vProperties.DefaultEncoding))
            {
                ResponsePDU resp = vTrans.SendPdu(pdu, timeOut);
                if (resp.Header.ErrorCode != SmppErrorCode.ESME_ROK)
                {
                    throw new SmppException(resp.Header.ErrorCode);
                }
                var submitSmResp = resp as SubmitSmResp;
                if (submitSmResp != null)
                {
                    messageId = ((SubmitSmResp)resp).MessageID;
                }
                message.ReceiptedMessageId = messageId;
                RaiseMessageSentEvent(message);
            }
        }
Exemple #2
0
        /// <summary>
        /// Sends message to a remote SMPP server
        /// </summary>
        /// <param name="message">A message to send</param>
        /// <param name="timeOut">A value in miliseconds after which the send operation times out</param>
        public void SendMessage(ShortMessage message, int timeOut)
        {
            if (message == null)
            {
                throw new ArgumentNullException("message");
            }

            //Check if connection is open
            if (vState != SmppConnectionState.Connected)
            {
                throw new SmppClientException("Sending message operation failed because the SmppClient is not connected");
            }

            string messageId = null;

            foreach (SendSmPDU pdu in message.GetMessagePDUs(vProperties.DefaultEncoding, vSmppEncodingService))
            {
                if (_Log.IsDebugEnabled)
                {
                    _Log.DebugFormat("SendMessage SendSmPDU: {0}", LoggingExtensions.DumpString(pdu, vSmppEncodingService));
                }
                ResponsePDU resp         = SendPdu(pdu, timeOut);
                var         submitSmResp = resp as SubmitSmResp;
                if (submitSmResp != null)
                {
                    if (_Log.IsDebugEnabled)
                    {
                        _Log.DebugFormat("SendMessage Response: {0}", LoggingExtensions.DumpString(resp, vSmppEncodingService));
                    }
                    messageId = ((SubmitSmResp)resp).MessageID;
                }
                message.ReceiptedMessageId = messageId;
                RaiseMessageSentEvent(message);
            }
        }