Skip to content

Sending Messages Asynchronously

Adham Awadhi edited this page May 9, 2017 · 2 revisions

For more information about receiving and sending messages synchronously, follow this guide Sending & Receiving Messages

Before you can start sending messages, you must first connect to an SMSC. For more information about connecting to an SMSC, read this guide Connecting to an SMSC

Sending messages asynchronously

Jamaa Smpp Client provides an asynchronous version of the SendMessage method for sending messages asynchronously without waiting for the operation to complete.

The following code snippet shows how to send message asynchronously.

TextMessage msg = new TextMessage();
//set msg properties

SmppClient client = GetSmppClient();
client.BeginSendMessage(msg, SendMessageCompleteCallback, client);
//continue with other stuff

Below is a method that will be called after the asynchronous operation completes:

private void SendMessageCompleteCallback(IAsyncResult result)
{
    SmppClient client = (SmppClient)result.AsyncState;
    client.EndSendMessage(result);
}
Clone this wiki locally