-
developerlearn999
- Posts: 85
- Joined: Thu Jun 20, 2019 9:34 am
Post
by developerlearn999 » Thu Jun 20, 2019 9:38 am
i try to use from the code example this line
.Set(delegate(SubmitSm sm) { sm.Sequence = _client.SequenceGenerator.NextSequenceNumber();})
the error is
Severity Code Description Project File Line Suppression State
Error CS1061 'SubmitSm' does not contain a definition for 'Sequence' and no accessible extension method 'Sequence' accepting a first argument of type 'SubmitSm' could be found (are you missing a using directive or an assembly reference?) SmppClientDemo C:\C#\Inetlab.SMPP\Samples\CS\SmppClientDemo\SmppClientDemo.cs 485 Active
i use intelab smpp V2
any idea?
-
alt
- Site Admin
- Posts: 988
- Joined: Tue Apr 25, 2006 9:45 am
Post
by alt » Sun Jun 23, 2019 1:33 pm
In SMPP protocol same sequence number have only SMPP command and corresponding response. f.i SubmitSm and SubmitSmResp.
Incoming SMS from mobile phone in DeliverSm has its own sequence number from SMPP server.
When you receive delivery receipt you should receive same MessageId in submitSmResp.MessageId and deliverSm.Receipt.MessageId.
Library by sending PDU checks if it already has Sequence number. If sequence number is 0, it assigns next number and sends this PDU.
-
developerlearn999
- Posts: 85
- Joined: Thu Jun 20, 2019 9:34 am
Post
by developerlearn999 » Sun Jun 23, 2019 4:32 pm
in the examples i saw i thought i can match by using the Sequence from the SubmitSm and DeliverSm
by setting them on my own (i want to have some id that i can match when i get the DeliverSm, since DeliverSm is incoming very fast
before i finish to parse the bulk of 100 or more sms that i send at once)
-
alt
- Site Admin
- Posts: 988
- Joined: Tue Apr 25, 2006 9:45 am
Post
by alt » Sun Jun 23, 2019 5:13 pm
You can create a task method that processes MessageId from SubmitSmResp right after submit, without waiting when you receive all 100 responses.
Code: Select all
public async Task SendSMS(SubmitSm sm)
{
SubmitSmResp resp = await _client.Submit(sm);
// Store MessageId
_repository.Save(resp.MessageId,...);
}
public async Task SubmitBatch(SubmitSm[] batch)
{
IList<Task> tasks = new List<Task>();
foreach (SubmitSm submitSm in batch)
{
tasks.Add(SendSMS(submitSm));
}
await Task.WhenAll(tasks);
}
-
developerlearn999
- Posts: 85
- Joined: Thu Jun 20, 2019 9:34 am
Post
by developerlearn999 » Sun Jun 23, 2019 5:18 pm
1. i do submitsm of 100 messages in 1 list for faster sending
2. since i do#1, some of the DelieverSm recievd faster then i finish to parse the messageid
-
alt
- Site Admin
- Posts: 988
- Joined: Tue Apr 25, 2006 9:45 am
Post
by alt » Mon Jun 24, 2019 4:59 pm
if you always receive delivery receipt for submitted message, you can wait for it and then process the result.
Code: Select all
public static async Task<IEnumerable<DeliverSm>> SendBatchAndWaitForDelivery(this SmppClient client,
IEnumerable<SubmitSm> list)
{
ConcurrentDictionary<string, TaskCompletionSource<DeliverSm>> deliveryTasks =
new ConcurrentDictionary<string, TaskCompletionSource<DeliverSm>>();
var onDeliver = new DeliverSmEventHandler((sender, data) =>
{
if (data.Receipt != null)
{
TaskCompletionSource<DeliverSm> task;
if (deliveryTasks.TryRemove(data.Receipt.MessageId, out task))
{
task.SetResult(data);
}
}
});
client.evDeliverSm += onDeliver;
List<Task> tasks = new List<Task>();
foreach (SubmitSm sm in list)
{
tasks.Add(client.Submit(sm).ContinueWith(t =>
{
TaskCompletionSource<DeliverSm> tcs = new TaskCompletionSource<DeliverSm>();
if (deliveryTasks.TryAdd(t.Result.MessageId, tcs))
{
return tcs.Task;
}
return Task.CompletedTask;
}));
}
await Task.WhenAll(tasks);
client.evDeliverSm -= onDeliver;
deliveryTasks.Clear();
return tasks.OfType<Task<DeliverSm>>().Select(x => x.Result);
}
You need some kind of process manager for submitted message that starts some work after receiving both SubmitSmResp and corresponding DeliverSm receipt.