Beispiel #1
0
        /// <summary> Called to create a SubmitSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitSmResp </returns>
        public static SubmitSmResp Create(DataCodings defaultEncoding,
                                          SmppBuffer buf,
                                          ref int offset)
        {
            var submitSmResp = new SubmitSmResp(defaultEncoding);

            try
            {
                var start_offset = offset;

                buf.ExtractHeader(submitSmResp,
                                  ref offset);

                if (submitSmResp.Length > HEADER_LENGTH)
                {
                    submitSmResp.MessageId = buf.ExtractCString(ref offset);

                    while (offset - start_offset < submitSmResp.Length)
                    {
                        submitSmResp.Optional.Add(buf.ExtractTLV(ref offset));
                    }
                }
            }

            catch { submitSmResp = null; }

            return(submitSmResp);
        }
Beispiel #2
0
        /// <summary> Called to send the message </summary>
        /// <param name="phoneNumber"></param>
        /// <param name="serviceType"></param>
        /// <param name="sourceTon"></param>
        /// <param name="sourceNpi"></param>
        /// <param name="submitDataCoding"></param>
        /// <param name="encodeDataCoding"></param>
        /// <param name="message"></param>
        /// <param name="submitSm"></param>
        /// <param name="submitSmResp"></param>
        /// <returns> 1 - Successful / 0 - Failed </returns>
        public int SendMessage(string phoneNumber,
                               string serviceType,
                               Ton sourceTon,
                               Npi sourceNpi,
                               DataCodings submitDataCoding,
                               DataCodings encodeDataCoding,
                               string message,
                               out SubmitSm submitSm,
                               out SubmitSmResp submitSmResp)
        {
            var retVal = 0;

            submitSm     = null;
            submitSmResp = null;

            try
            {
                // Capture the next transmitter connection
                var smppConnection = NextTransmitterConnection();

                if (smppConnection == null)
                {
                    WriteLog("ESMEManager : SendMessage : Warning : Not Bound To The SMPP Server");

                    return(2);
                }

                // Send the message
                retVal = smppConnection.SendMessage(phoneNumber,
                                                    serviceType,
                                                    sourceTon,
                                                    sourceNpi,
                                                    submitDataCoding,
                                                    encodeDataCoding,
                                                    message,
                                                    out submitSm,
                                                    out submitSmResp);
            }

            catch (Exception exception)
            {
                WriteLog(LogEventNotificationTypes.Email,
                         "ESMEManager : SendMessage : ERROR : {0}",
                         exception.ToString());
            }

            return(retVal);
        }