Sending Messages Asynchronously

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);
}

Last edited Apr 17, 2011 at 12:28 PM by bentesha, version 2

Comments

No comments yet.