/// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="submitMultiSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> SubmitMultiSmResp </returns>
        public static SubmitMultiSmResp Create(DataCodings defaultEncoding, SubmitMultiSm submitMultiSm, CommandStatus commandStatus, string messageId)
        {
            if (submitMultiSm.SourceAddr == string.Empty || submitMultiSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return(new SubmitMultiSmResp(defaultEncoding, commandStatus, submitMultiSm.Sequence, messageId));
        }
Beispiel #2
0
        /// <summary> Called to create a SubmitMulti object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitMulti </returns>
        public static SubmitMultiSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            SubmitMultiSm submitMulti = new SubmitMultiSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(submitMulti, ref offset);

                submitMulti.ServiceType          = buf.ExtractCString(ref offset);
                submitMulti.SourceTon            = buf.ExtractByte(ref offset);
                submitMulti.SourceNpi            = buf.ExtractByte(ref offset);
                submitMulti.SourceAddr           = buf.ExtractCString(ref offset);
                submitMulti.DestinationAddresses = buf.ExtractDestinationAddresses(ref offset);
                submitMulti.EsmClass             = buf.ExtractByte(ref offset);
                submitMulti.ProtocolId           = buf.ExtractByte(ref offset);
                submitMulti.PriorityFlag         = buf.ExtractByte(ref offset);
                submitMulti.ScheduleDeliveryTime = buf.ExtractCString(ref offset);
                submitMulti.ValidityPeriod       = buf.ExtractCString(ref offset);
                submitMulti.RegisteredDelivery   = buf.ExtractByte(ref offset);
                submitMulti.ReplaceIfPresent     = buf.ExtractByte(ref offset);
                submitMulti.DataCoding           = (DataCodings)buf.ExtractByte(ref offset);
                submitMulti.DefaultMsgId         = buf.ExtractByte(ref offset);
                submitMulti.ShortMessageLength   = buf.ExtractByte(ref offset);

                if (submitMulti.ShortMessageLength > 0)
                {
                    submitMulti.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, submitMulti.ShortMessageLength));
                }

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

            catch
            {
                submitMulti = null;
            }

            return(submitMulti);
        }
        /// <summary> Called to create a DataSmResp object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="submitMultiSm"></param>
        /// <param name="commandStatus"></param>
        /// <param name="messageId"></param>
        /// <returns> SubmitMultiSmResp </returns>
        public static SubmitMultiSmResp Create(DataCodings defaultEncoding, SubmitMultiSm submitMultiSm, CommandStatus commandStatus, string messageId)
        {
            if (submitMultiSm.SourceAddr == string.Empty || submitMultiSm.SourceAddr == null)
            {
                commandStatus = CommandStatus.ESME_RINVSRCADR;
            }

            return new SubmitMultiSmResp(defaultEncoding, commandStatus, submitMultiSm.Sequence, messageId);
        }
Beispiel #4
0
        /// <summary> Called to fire the submit multi pdu event </summary>
        /// <param name="data"></param>
        /// <param name="messageId"></param>
        /// <returns> CommandStatus </returns>
        internal CommandStatus OnSubmitMultiSm(SubmitMultiSm data, out string messageId)
        {
            CommandStatus commandStatus = CommandStatus.ESME_RSUBMITFAIL;
            messageId = null;

            try
            {
                if (SubmitMultiSmEvent != null)
                {
                    commandStatus = SubmitMultiSmEvent(this, data, out messageId);
                }
            }

            catch
            {
            }

            return commandStatus;
        }
Beispiel #5
0
        /// <summary> Submit a short message to the SMSC</summary>
        /// <param name="data"></param>
        /// <returns> A SubmitMultiResp object </returns>
        public SubmitMultiSmResp Submit(SubmitMultiSm data)
        {
            SubmitMultiSmResp submitMultiSmResp = null;
            EventData eventData = null;

            if (_Status != ConnectionStatus.Bound)
            {
                return SubmitMultiSmResp.Create(DefaultEncoding, CommandStatus.SMPPCLIENT_UNBOUND, data.Sequence);
            }

            try
            {
                // Request an event data object for the submit
                eventData = RequestEventData();

                // Add the event data object to the submit done list
                lock (SubmitDone)
                {
                    SubmitDone.Add(data.Sequence, eventData);
                }

                // Send the submit
                SendPacket(data);

                // Wait the response
                bool success = eventData.SignalEvent.WaitOne(5000);

                if (success == true)
                {
                    // Return the response
                    submitMultiSmResp = (SubmitMultiSmResp) eventData.ResponseObject;
                }
                else
                {
                    submitMultiSmResp = SubmitMultiSmResp.Create(DefaultEncoding, CommandStatus.SMPPCLIENT_RCVTIMEOUT, data.Sequence);
                }
            }

            catch (Exception exception)
            {
                OnError("Submit Multi error : ", exception);

                submitMultiSmResp = SubmitMultiSmResp.Create(DefaultEncoding, CommandStatus.SMPPCLIENT_UNKNOWNERROR, data.Sequence);
            }

            // Remove the submit done object
            lock (SubmitDone)
            {
                SubmitDone.Remove(data.Sequence);
            }

            // Release the event data
            ReleaseEventData(eventData);

            return submitMultiSmResp;
        }
Beispiel #6
0
        /// <summary> Called to create a SubmitMulti object </summary>
        /// <param name="defaultEncoding"></param>
        /// <param name="buf"></param>
        /// <param name="offset"></param>
        /// <returns> SubmitMulti </returns>
        public static SubmitMultiSm Create(DataCodings defaultEncoding, SmppBuffer buf, ref int offset)
        {
            SubmitMultiSm submitMulti = new SubmitMultiSm(defaultEncoding);

            try
            {
                int start_offset = offset;

                buf.ExtractHeader(submitMulti, ref offset);

                submitMulti.ServiceType = buf.ExtractCString(ref offset);
                submitMulti.SourceTon = buf.ExtractByte(ref offset);
                submitMulti.SourceNpi = buf.ExtractByte(ref offset);
                submitMulti.SourceAddr = buf.ExtractCString(ref offset);
                submitMulti.DestinationAddresses = buf.ExtractDestinationAddresses(ref offset);
                submitMulti.EsmClass = buf.ExtractByte(ref offset);
                submitMulti.ProtocolId = buf.ExtractByte(ref offset);
                submitMulti.PriorityFlag = buf.ExtractByte(ref offset);
                submitMulti.ScheduleDeliveryTime = buf.ExtractCString(ref offset);
                submitMulti.ValidityPeriod = buf.ExtractCString(ref offset);
                submitMulti.RegisteredDelivery = buf.ExtractByte(ref offset);
                submitMulti.ReplaceIfPresent = buf.ExtractByte(ref offset);
                submitMulti.DataCoding = (DataCodings) buf.ExtractByte(ref offset);
                submitMulti.DefaultMsgId = buf.ExtractByte(ref offset);
                submitMulti.ShortMessageLength = buf.ExtractByte(ref offset);

                if (submitMulti.ShortMessageLength > 0)
                {
                    submitMulti.UserDataBuffer = new SmppBuffer(defaultEncoding, buf.ExtractByteArray(ref offset, submitMulti.ShortMessageLength));
                }

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

            catch
            {
                submitMulti = null;
            }

            return submitMulti;
        }