Share via


Inviting a Participant to a Signaling Session

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

To send a signaling session INVITE request to the remote participant, an application calls the Participate or BeginParticipate method. The former is the synchronous form and the latter is the asynchronous form.

Sending a Session INVITE Synchronously

The following code example illustrates how to send a signaling session INVITE request to the remote participant.

// Invite synchronously.
// The inviter does not care which endpoint accepts.

SignalingSession session = ...;
try
{
  session.Participate();
}

catch (RealTimeException exp)
{
  // Handle exception.
  Console.WriteLine("Invite Failure for {0}: {1}", 
                     session.RemoteParticipant.Uri,
                     exp.ToString);
}

Sending a Session INVITE with Custom Headers

The following code example illustrates how to send a signaling session INVITE request with custom headers synchronously.

// Invite synchronously.
// The inviter wants to specify some custom headers
List<SignalingHeader> signalingHeaders = 
                         new List<SignalingHeader>();
signalingHeaders.Add(new SignalingHeader( 
                                         "Custom-Header-Name1", 
                                         "Custom-Header-Value1" )
                                         );
signalingHeaders.Add(new SignalingHeader( 
                                         "Custom-Header-Name2", 
                                         "Custom-Header-Value2" ) 
                                        );

try
{
  session.Participate( signalingHeaders );
}

catch (RealTimeException exp)
{
  // Handle exception.
  Console.WriteLine("Invite Failure for {0}: {1}", 
                     session.RemoteParticipant.Uri,
                     exp.ToString);
}

Sending a Session INVITE Asynchronously

The following code example illustrates how to send a signaling session INVITE request asynchronously.

// Invite a URI asynchronously. 
AsyncCallback inviteCallback = 
             new AsyncCallback(Participate_Completed);
try
{
  session.BeginParticipate(inviteCallback, session);
}

catch (RealTimeException exp)
{
  // Handle exception.
  Console.WriteLine("Invite Failure: {0}", exp);
}

void Participate_Completed(IAsyncResult asyncResult)
{
  SignalingSession session = 
                 (SignalingSession) asyncResult.AsyncState;
  try
  {
    session.EndParticipate(asyncResult);
  }

  catch (FailureResponseException exp)
  {
    // Handle a failure response
    Console.WriteLine("Failure response for {0}: {1}",
                       session.RemoteParticipant.Uri,
                       exp.ToString());
  }

  catch (OperationTimeoutException exp)
  {
    // Operation timed out
    Console.WriteLine("Operation timed out for {0}: {1}",
                       session.RemoteParticipant.Uri,
                       exp.ToString());
  }

  catch (RealTimeException exp)
  {
    // Handle exception.
    Console.WriteLine("Invite Failure for {0}: {1}", 
                       session.RemoteParticipant.Uri,
                       exp.ToString());
  }
}

See Also

Concepts

Signaling Session
Creating an Outgoing Signaling Session