Edit

Share via


Call.BeginAccept Method

Definition

Overloads

BeginAccept(AsyncCallback, Object)

Accepts an incoming call.

BeginAccept(CallAcceptOptions, AsyncCallback, Object)

Accepts an incoming call with given options.

BeginAccept(AsyncCallback, Object)

Accepts an incoming call.

public:
 IAsyncResult ^ BeginAccept(AsyncCallback ^ userCallback, System::Object ^ state);
public IAsyncResult BeginAccept (AsyncCallback userCallback, object state);
member this.BeginAccept : AsyncCallback * obj -> IAsyncResult
Public Function BeginAccept (userCallback As AsyncCallback, state As Object) As IAsyncResult

Parameters

userCallback
AsyncCallback

The method to be called when the asynchronous operation is completed.

state
Object

A user-provided object that distinguishes this particular asynchronous operation from other asynchronous operations.

Returns

An IAsyncResult that references the asynchronous operation.

Exceptions

Thrown when the call is in invalid state to perform this operation.

Examples

This example demonstrates how to accept an incoming call. This example assumes that the endpoint has already been established and the delegate to receive calls has been registered.

C# Receiving and accepting an incoming call


// Register for incoming calls on receiving endpoint.
endpoint2.RegisterForIncomingCall<InstantMessagingCall>(
    this.IncomingCallReceived);


private void IncomingCallReceived(
    object sender,
    CallReceivedEventArgs<InstantMessagingCall> e)
{

    try
    {
        e.Call.InstantMessagingFlowConfigurationRequested += this.FlowConfigurationRequested;

        // Accept the call. This will cause FlowConfigurationRequested to be raised.
        e.Call.BeginAccept(this.AcceptCompleted, e.Call);
    }
    catch (InvalidOperationException)
    {
        // Call got disconnected before it could be accepted
        // TODO: Replace with exception handling code.
        Console.WriteLine("Call was disconnected.");
    }
}

private void AcceptCompleted(IAsyncResult result)
{
    try
    {
        InstantMessagingCall call = result.AsyncState as InstantMessagingCall;

        call.EndAccept(result);
    }
    catch (RealTimeException exception)
    {
        // TODO: Replace with exception handling code.
        Console.WriteLine("Call accept failed: {0}", exception.Message);
    }
    finally
    {
        // TODO: Add clean up code here.
    }

}


Remarks

The state of the call can change if the remote party decides to cancel the call.

Applies to

BeginAccept(CallAcceptOptions, AsyncCallback, Object)

Accepts an incoming call with given options.

public:
 IAsyncResult ^ BeginAccept(Microsoft::Rtc::Collaboration::CallAcceptOptions ^ options, AsyncCallback ^ userCallback, System::Object ^ state);
public IAsyncResult BeginAccept (Microsoft.Rtc.Collaboration.CallAcceptOptions options, AsyncCallback userCallback, object state);
member this.BeginAccept : Microsoft.Rtc.Collaboration.CallAcceptOptions * AsyncCallback * obj -> IAsyncResult
Public Function BeginAccept (options As CallAcceptOptions, userCallback As AsyncCallback, state As Object) As IAsyncResult

Parameters

options
CallAcceptOptions

Optional parameters to be used when accepting the call.

userCallback
AsyncCallback

The method to be called when the asynchronous operation is completed.

state
Object

A user-provided object that distinguishes this particular asynchronous operation from other asynchronous operations.

Returns

An IAsyncResult that references the asynchronous operation.

Exceptions

Thrown when the options parameter contains invalid headers, restricted headers or invalid accepted content identifiers.

Thrown when the call is in an invalid state to perform this operation.

Applies to