Sending Page-Mode Messages Synchronously

The following code example shows how to send a simple text message synchronously in page mode. It is assumed that the endpoint is properly created and registered, if it is registration-based. In this example, the message is sent using a call to the SendMessage(MessageType, RealTimeAddress, ContentType, []) method on the endpoint.

RealTimeEndpoint endpoint = ...; // Assumed to be created elsewhere
RealTimeAddress target = new RealTimeAddress("sip:bob@contoso.com");
string msg = "Greetings!";
ContentType contentType = new ContentType("text/plain; charset=UTF-8");
byte[] msgBody = Encoding.UTF8.GetBytes(msg);
try
{
  endpoint.SendMessage(MessageType.Message,
                       target,
                       contentType,
                       msgBody);
}

catch (RealTimeException e)
{
  // Handle exception.
}