Share via


Accepting or Declining a Session Referral

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.

After one participant in a signaling session sends a REFER request, the referred-to application can either accept or decline. The general programming patterns for accepting or declining a referral are described in this topic.

Accepting or Declining a REFER Request

The referred-to application receives a REFER request if it has subscribed to the ReferReceived event on the SignalingSession object. The application can either accept or decline the REFER request in the implementation of the event handler. The decision to accept or decline a REFER request often involves some user interactions. The following code example illustrates this process.

The handler for the ReferReceived event accepts the REFER by calling Accept, and declines this message by calling Decline or DeclineWithResponse.

SignalingSession session = ...; // Assumed to be defined elsewhere

// Subscribe to ReferReceived events to receive REFER requests
session.ReferReceived += this.OnReferReceived;

// Handle a received REFER request
void OnReferReceived(object sender, ReferReceivedArgs e)
{
  SignalingSession s = sender as SignalingSession;
  RealTimeAddress referAddress = e.ReferTarget;
  String referMethod = e.Method; // Can be null. Retrieved from method= parameter of refer-to header.
  // 
  // Prompt the user about the Refer with referTo-Uri 
  //   and referFrom-Uri.
  // The prompt should return the result in fAccepted
  // 
  if( fAccepted )
  {
    // Accept REFER with null custom signaling headers.
    ReferNotifier notifier = e.Accept(null);

    // Send notifications to the remote endpoint
    notifier.SetState(ReferState.Trying);
  }   

  else
  {
    e.Decline(); 
    // OR
    // e.DeclineWithResponse(ResponseCode.BusyHere, null, null);
  }
}   

See Also

Concepts

Signaling Session