本文整理汇总了C#中Conversation.Impersonate方法的典型用法代码示例。如果您正苦于以下问题:C# Conversation.Impersonate方法的具体用法?C# Conversation.Impersonate怎么用?C# Conversation.Impersonate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conversation
的用法示例。
在下文中一共展示了Conversation.Impersonate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleIncomingCall
internal void HandleIncomingCall()
{
Console.WriteLine("Handling incoming IM call.");
// Create a new conversation for the back-end leg of the B2B call (which will connect to the conference).
LocalEndpoint localEndpoint = _frontEndCallLeg.Conversation.Endpoint;
Conversation backEndConversation = new Conversation(localEndpoint);
// Impersonate the caller so that the caller, rather than the application, will appear to be participating in the conference
string callerSipUri = _frontEndCallLeg.RemoteEndpoint.Participant.Uri;
backEndConversation.Impersonate(callerSipUri, null, null);
Console.WriteLine("Caller SIP Uri: " + callerSipUri);
try
{
// Join the conference
backEndConversation.ConferenceSession.BeginJoin(
default(ConferenceJoinOptions),
joinAsyncResult =>
{
try
{
backEndConversation.ConferenceSession.EndJoin(joinAsyncResult);
Console.WriteLine("Joined conference.");
_backEndCallLeg = new InstantMessagingCall(backEndConversation);
CreateBackToBack();
}
catch (RealTimeException ex)
{
Console.WriteLine(ex);
}
},
null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine(ex);
}
}
示例2: Execute
public override async Task<AcdActionResult> Execute(LocalEndpoint localEndpoint, AudioVideoCall call, CancellationToken cancellationToken)
{
if (Endpoint == null)
return AcdActionResult.Continue;
// extract information from incoming caller
var callParticipant = call.RemoteEndpoint.Participant;
var callAddress = new RealTimeAddress(callParticipant.Uri, localEndpoint.DefaultDomain, localEndpoint.PhoneContext);
var callSipUri = new SipUriParser(callAddress.Uri);
callSipUri.RemoveParameter(new SipUriParameter("user", "phone"));
var callUri = callSipUri.ToString();
var callPhoneUri = callParticipant.OtherPhoneUri;
var callName = callParticipant.DisplayName;
// impersonate incoming caller to agent
var remoteConversation = new Conversation(localEndpoint);
remoteConversation.Impersonate(callUri, callPhoneUri, callName);
// establish call to endpoint
var remoteCall = new AudioVideoCall(remoteConversation);
var remoteOpts = new CallEstablishOptions();
remoteOpts.Transferor = localEndpoint.OwnerUri;
remoteOpts.Headers.Add(new SignalingHeader("Ms-Target-Class", "secondary"));
// initiate call with duration
var destCallT = remoteCall.EstablishAsync(Endpoint.Uri, remoteOpts, cancellationToken);
try
{
// wait for agent call to complete
await destCallT;
}
catch (OperationCanceledException)
{
// ignore
}
catch (RealTimeException)
{
// ignore
}
// ensure two accepted transfers cannot both complete
using (var lck = await call.GetContext<AsyncLock>().LockAsync())
if (call.State == CallState.Established)
if (remoteCall.State == CallState.Established)
{
var participant = remoteConversation.RemoteParticipants.FirstOrDefault();
if (participant != null)
{
var endpoint = participant.GetEndpoints().FirstOrDefault(i => i.EndpointType == EndpointType.User);
if (endpoint != null)
{
var ctx = new ConversationContextChannel(remoteConversation, endpoint);
// establish conversation context with application
await ctx.EstablishAsync(
new Guid("FA44026B-CC48-42DA-AAA8-B849BCB43A21"),
new ConversationContextChannelEstablishOptions());
// send context data
await ctx.SendDataAsync(
new ContentType("text/plain"),
Encoding.UTF8.GetBytes("Id=123"));
}
}
return await TransferAsync(call, remoteCall);
}
// terminate outbound call if still available
if (remoteCall.State != CallState.Terminating &&
remoteCall.State != CallState.Terminated)
await remoteCall.TerminateAsync();
// we could not complete the transfer attempt
return AcdActionResult.Continue;
}
示例3: EscalateCalltoConference
// Escalate call to a conference
public void EscalateCalltoConference(AudioVideoCall call, string recipient)
{
_frontEndCallLeg = call;
_recipient = recipient;
Console.WriteLine("Escalating incoming call to conference");
LocalEndpoint localEndpoint = _frontEndCallLeg.Conversation.Endpoint;
Conversation backEndConversation = new Conversation(localEndpoint);
string callerSipUri = _frontEndCallLeg.RemoteEndpoint.Participant.Uri;
backEndConversation.Impersonate(callerSipUri, null, null);
Console.WriteLine("Caller SIP Uri: " + callerSipUri);
try
{
ConferenceJoinOptions options = new ConferenceJoinOptions();
options.JoinMode = JoinMode.TrustedParticipant;
backEndConversation.ConferenceSession.BeginJoin(
options,
joinAsyncResult =>
{
try
{
backEndConversation.ConferenceSession.EndJoin(joinAsyncResult);
Console.WriteLine("Joined conference.");
_backEndCallLeg = new AudioVideoCall(backEndConversation);
CreateBackToBackCall();
}
catch (RealTimeException ex)
{
Console.WriteLine("Failed to join conference when escalating the call.\n{0}", ex);
}
},
null);
}
catch (InvalidOperationException ex)
{
Console.WriteLine("Failed to escalate call to conference: {0}", ex);
}
}