Send messages
The SMPP-server creates SmppServerClient object automatically for each SMPP-client connected. Calling method DeliverAsync of the SmppServerClient object sends a message to the respective SMPP-client.
To start, it is necessary to choose SmppServerClient instance from the list available at ConnectedClients property. You may use any SmppServerClient properties as criteria for choosing the recipient/SMPP-client.
For example, let us crate arbitrary message at SMPP-server and send it to the SMPP-client. To choose a recipient SMPP-client from the list we will use SystemID value (SMPP-client login). The message will be sent to the first client having SystemID matching field "To" value of the message.
Assuming the SMPP-server already created, minimally configured and started and the server parameter will be passed to the method, the sending method will be as follows:
public async Task SendSms(SmppServer _server)
{
//prepare message data
string sender = "123";
string recipient = "456";
string text = "hello!";
//searching recepient by criteria
SmppServerClient clientRecepient = _server.ConnectedClients.FirstOrDefault(c => c.SystemID == recipient);
//creating message and sending
if (clientRecepient != null)
{
IList<DeliverSm> textMessage = SMS.ForDeliver().From(sender).To(recipient).Text(text).Create(clientRecepient);
IEnumerable<DeliverSmResp> response = await clientRecepient.DeliverAsync(textMessage);
}
}
To have a message sent in the example above, the SMPP-server must have an SMPP-client with SystemId “456” already connected when method SendSms is called.