Accepting an Incoming Call

To listen for incoming calls, an application must register the handler with RegisterForIncomingCall<TCall>. When an incoming INVITE is received on an endpoint, the endpoint uses the factory to create the appropriate type of call and raise the event to the application. The application can call BeginAccept() to accept the call, or Decline() to decline the call. If the incoming call contains MIME parts, the application must specify the accepted Content-ID values list on the call to BeginAccept.

//Register the event handler to receive the incoming AudioVideoCall.

// Handler to receive and accept the incoming AudioVideoCall.
private void Endpoint_CallReceived(object sender, CallReceivedEventArgs<AudioVideoCall> e)
  incomingCall = e.Call;
  //process MIME parts if interested.
  Collection<MimePartContentDescription> callMimeParts = e.CustomMimeParts;

  //Register call event handlers. 
  incomingCall.StateChanged += CallStateChanged;

  //Accept the call.
  //The following code specifies no custom headers or accepted content-ids when accepting the call.
  incomingCall.BeginAccept(null, IncomingCallEstablished, incomingCall);

//Call state changed handler.
private void CallStateChanged(object o, CallStateChangedEventArgs eArg)
  Console.WriteLine("Call state changed: {0} {1}", eArg.PreviousState, eArg.State);

An incoming invitation with any MIME part that specifies "handling=required" for a content type will be rejected if the application does not specify the associated content type as a type that is supported by the endpoint. If the parts are in a mime/alternate section, then the application must support at least one of the parts.