How to pass unique parameter to Inetlab client, like database Id?

384 views Asked by At

I have some sms in database and I want to update their status when all task will be completed, I don't want to use task.Result or await on each submit becouse it works very slow. I need to pass sms Id to the clients and get the Id on response. I use Inetlab. any suggestions?

            var messagesNumber = 30;
            List<Task<SubmitSmResp[]>> tasks = new List<Task<SubmitSmResp[]>>();

            for (int i = 0; i < messagesNumber; i++)
            {
                tasks.Add(client.SubmitAsync(
                          SMS.ForSubmit()
                           .AddUserDataHeader(new Inetlab.SMPP.Headers.UserDataHeader(1, new byte[2]))
                              .From("test")
                              .To("2323")
                              .Coding(DataCodings.UCS2)
                              .Text($"{i}test")));
            }

            await Task.WhenAll(tasks);
            int k = 0; var thr = 0;
            foreach (var t in tasks)
            {
                var res = (SubmitSmResp[])t.Result;
                var ss = res.Select(x => x.Header.Sequence);
                if (res.All(x => x.Header.Status == CommandStatus.ESME_ROK))
                {
                    //want to update this sms in database,I need sms Id
                }
                if (res.All(x => x.Header.Status == CommandStatus.ESME_RTHROTTLED))
                {
                    //want to update this sms in database,I need sms Id
                    thr++;
                }
            }

2

There are 2 answers

1
miciry89 On

GUID could be an option. You can use as a unique identifier.

0
Andi Thomaj On

What you can do in that case so that you can preserve the ID both on transmitting and receiving is to use a parameter. You can append the parameter when you prepare the sms for submit. Please take a look at the official documentation: https://docs.inetlab.com/smpp/v2/api/Inetlab.SMPP.Parameters.TLV.html