Resending message part

.NET library for SMPP protocol
Locked
Wombat
Posts: 4
Joined: Sat Jun 16, 2012 2:07 pm

Resending message part

Post by Wombat » Sat Jun 16, 2012 2:29 pm

Dear alt,
I'm going to purchase your SMPP client/server implementation, so I'm testing this wonderful library at this time. I'm confused with resending one part of long sms. For sending message I'm doing smth like this:

Code: Select all

ushort refNumber = 0;
.... somewhere in cycle:

Code: Select all

refNumber = (ushort)(refNumber + (ushort)1);
if ((refNumber == 0) || (refNumber >= 65535))
{
    refNumber = 1;
} else {
    refNumber = (ushort)(refNumber + (ushort)1);
}
SubmitSm submit_sm = new SubmitSm();
submit_sm.DataCoding = (DataCodings)codings[sms[i].sms_group_id];
submit_sm.DestAddr = sms[i].phone;
submit_sm.DestNpi = channelInfo.dest_addr_npi;
submit_sm.DestTon = channelInfo.dest_addr_ton;
submit_sm.MessageMode = MessageModes.Default;
submit_sm.MessageType = MessageTypes.Default;
submit_sm.RegisteredDelivery = 1;
submit_sm.ReplaceIfPresent = 0;
submit_sm.ScheduleDeliveryTime = null;
submit_sm.Sequence = (uint)sms[i].server_id;
submit_sm.SrcAddr = sms[i].sender_sign;
submit_sm.SrcNpi = channelInfo.source_addr_npi;
submit_sm.SrcTon = channelInfo.source_addr_ton;
submit_sm.UserDataPdu = new UserData();
switch ((DataCodings)codings[sms[i].sms_group_id])
{
    case DataCodings.Latin1: { submit_sm.UserDataPdu.ShortMessage = Encoding.GetEncoding("iso8859-1").GetBytes(sms[i].sms_text); } break;
    default: { submit_sm.UserDataPdu.ShortMessage = Encoding.BigEndianUnicode.GetBytes(sms[i].sms_text); } break;
}
if (!((sms[i].sms_group_count == 0) || (sms[i].sms_group_count == 1)))
{
    submit_sm.Optional.AddSARReferenceNumber((ushort)[b]refNumber[/b]);
    submit_sm.Optional.AddSARSequenceNumber((byte)sms[i].sms_group_index);
    submit_sm.Optional.AddSARTotalSegments((byte)sms[i].sms_group_count);
}
submit_sm.ValidityPeriod = DateTime.Now.AddDays(1).ToString("yyMMddhhmmss000+");
client.SubmitAsync(submit_sm);
where refNumber is dynamically calculated in cycle.
I don't know what to to do when i receive throatling (for example) error for one part of multipart sms message. How to process resending only one part of multipart message: ReferenceNumber may not be unique? I hope for your answer!
p.s. sorry for my English, please.
alt
Site Admin
Posts: 918
Joined: Tue Apr 25, 2006 9:45 am

Re: Resending message part

Post by alt » Mon Jun 18, 2012 6:11 pm

Hi Wombat,

You can try to resend same message in the event handler evSubmitComplete when you receive response with status ESME_RTHROTTLED.
Before repeat sending you have to change SubmitSm PDU sequence number.
You don't need to change concatenation reference number in TLV parameters.

Do you have a reason to split long message with your code? Note you can use client.PrepareSubmit method to get SMPP message parts for long text.
Wombat
Posts: 4
Joined: Sat Jun 16, 2012 2:07 pm

Re: Resending message part

Post by Wombat » Tue Jun 19, 2012 9:00 am

Thanks for your answer!
I've done this otherwise by creating Hashtable which establishes a correspondence between my serverids and referencenumbers, and I changed the logic of calculating new referencenumber to ensure its uniqueness for new messages, but your advice seems to be more elegant.
I've tried to use client.PrepareSubmit, but splitting sms manually is more suitable for me because they are splitted in database.
Thanks again!
Locked