LocalEndpoint.RegisterForIncomingCall<TCall> Method
Registers a delegate to handle incoming calls for a specific modality.
Namespace: Microsoft.Rtc.Collaboration
Assembly: Microsoft.Rtc.Collaboration (in Microsoft.Rtc.Collaboration.dll)
Syntax
'Declaration
Public Sub RegisterForIncomingCall(Of TCall As Call) ( _
incomingCallDelegate As IncomingCallDelegate(Of TCall) _
)
'Usage
Dim instance As LocalEndpoint
Dim incomingCallDelegate As IncomingCallDelegate(Of TCall)
instance.RegisterForIncomingCall(incomingCallDelegate)
public void RegisterForIncomingCall<TCall>(
IncomingCallDelegate<TCall> incomingCallDelegate
)
where TCall : Call
Type Parameters
- TCall
The Call-derived type to be handled.
Parameters
- incomingCallDelegate
Type: Microsoft.Rtc.Collaboration.IncomingCallDelegate<TCall>
The delegate method to handle the call.
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.
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.
}
}