Receiving Page-Mode Messages
Subscribing to the event amounts to registering for notification when a MessageReceived event is raised, and implementing a handler for this event. The following is a simple code example that illustrates this process.
RealTimeEndpoint endpoint = ...; // Assumed to be created elsewhere.
endpoint.MessageReceived += pageMode_MessageReceived;
void pageMode_MessageReceived(object sender, MessageReceivedEventArgs e)
{
if ((e.ContentType.MediaType.CompareTo("text/plain") == 0) &&
(e.ContentType.CharSet.CompareTo("utf-8") == 0) &&
(e.HasTextBody == true))
{
string msg = Encoding.UTF8.GetString(e.GetBody());
Console.WriteLine(msg);
}
else
{
// Handle other media types and other character encoding types.
}
}