LocalEndpoint.RegisterForIncomingCall<TCall> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Registers a delegate to handle incoming calls for a specific modality.
public:
generic <typename TCall>
where TCall : Microsoft::Rtc::Collaboration::Call void RegisterForIncomingCall(Microsoft::Rtc::Collaboration::IncomingCallDelegate<TCall> ^ incomingCallDelegate);
public void RegisterForIncomingCall<TCall> (Microsoft.Rtc.Collaboration.IncomingCallDelegate<TCall> incomingCallDelegate) where TCall : Microsoft.Rtc.Collaboration.Call;
member this.RegisterForIncomingCall : Microsoft.Rtc.Collaboration.IncomingCallDelegate<'Call (requires 'Call :> Microsoft.Rtc.Collaboration.Call)> -> unit (requires 'Call :> Microsoft.Rtc.Collaboration.Call)
Public Sub RegisterForIncomingCall(Of TCall As Call) (incomingCallDelegate As IncomingCallDelegate(Of TCall))
Type Parameters
- TCall
The Call-derived type to be handled.
Parameters
- incomingCallDelegate
- IncomingCallDelegate<TCall>
The delegate method to handle the call.
Examples
This example demonstrates how to perform basic processing of in incoming call. This example assumes that the endpoint has already been established.
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 use of generics enable the communication framework to be extended to support custom modalities other than audio, video or instant messaging.
Only one delegate can be registered per TCall
type. Subsequent calls to this method will overwrite the previously set delegate.