Edit

Share via


InstantMessagingFlow.MessageReceived Event

Definition

Raised when a message is received.

public:
 event EventHandler<Microsoft::Rtc::Collaboration::InstantMessageReceivedEventArgs ^> ^ MessageReceived;
public event EventHandler<Microsoft.Rtc.Collaboration.InstantMessageReceivedEventArgs> MessageReceived;
member this.MessageReceived : EventHandler<Microsoft.Rtc.Collaboration.InstantMessageReceivedEventArgs> 
Public Custom Event MessageReceived As EventHandler(Of InstantMessageReceivedEventArgs) 

Event Type

Examples

This example demonstrates how to receive messages from the remote application. This code assumes that FlowConfigurationRequested event was registered on the call.

C# Receiving messages


private void FlowConfigurationRequested(
    object sender,
    InstantMessagingFlowConfigurationRequestedEventArgs e)
{

    // Register to receive messages.
    e.Flow.MessageReceived += this.MessageReceived;

}        

private void MessageReceived(
    object sender,
    InstantMessageReceivedEventArgs e)
{
    // Assumes only text messages are received.
    Console.WriteLine("Message with content type {0} received: Text: {1}", e.ContentType.ToString(), e.TextBody);

}


This example demonstrates how to receive messages from the remote application. This code assumes that FlowConfigurationRequested event was registered on the call.

C# Receiving messages

This example demonstrates how to receive messages from the remote application. This code assumes that FlowConfigurationRequested event was registered on the call.

C# Receiving messages


private void FlowConfigurationRequested(
    object sender,
    InstantMessagingFlowConfigurationRequestedEventArgs e)
{

    // Register to receive messages.
    e.Flow.MessageReceived += this.MessageReceived;

}        

private void MessageReceived(
    object sender,
    InstantMessageReceivedEventArgs e)
{
    // Assumes only text messages are received.
    Console.WriteLine("Message with content type {0} received: Text: {1}", e.ContentType.ToString(), e.TextBody);

    if (e.MessageId != null)
    {
        // We are expected to send a delivery notification.

        // Invoke some method to transmit the message via another mechanism.
        // Delivery does not have to be completed before the event handler returns.
        object[] state = new object[] { sender /* the flow */, e.MessageId };

        m_proxy.BeginSendMessageToClient(
            e.TextBody,
            this.SendMessageToClientCompleted,
            state);
    }

}


Applies to