目标是开发一个模块的系统监控解决方案接口,该模块呼叫值班人员并播放文件系统中的一些语音/音频文件。
我有一个skype for business 2015(以前的lync)用户,启用了电话选项。我也能打电话给一个号码。但接下来的问题是,如何等待被拨打的人接受电话并播放音频文件(或者更好的是系统)。语音变体而不是播放音频文件),之后该人必须批准他/她接到了电话。
我目前拥有的:
public void SendLyncCall(string numberToCall, string textToSpeech)
{
var targetContactUris = new List<string> {numberToCall}; //"tel:+4900000000" }; //removed here
_automation.BeginStartConversation(AutomationModalities.Audio, targetContactUris, null, StartConversationCallback, null);
while (this.globalConv == null)
{
Thread.Sleep(1);
}
if (globalConv != null)
{
LyncClient client = LyncClient.GetClient();
client.DeviceManager.EndPlayAudioFile(
client.DeviceManager.BeginPlayAudioFile(@"d:tmptest1.wav",
AudioPlayBackModes.Communication,
false,
null,
null));
}
}
private void StartConversationCallback(IAsyncResult asyncop)
{
// this is called once the dialing completes..
if (asyncop.IsCompleted == true)
{
ConversationWindow newConversationWindow = _automation.EndStartConversation(asyncop);
globalConv = newConversationWindow;
AVModality avModality = globalConv.Conversation.Modalities[ModalityTypes.AudioVideo] as AVModality;
foreach (char c in "SOS")
{
avModality.AudioChannel.BeginSendDtmf(c.ToString(), null, null);
System.Threading.Thread.Sleep(300);
}
}
}
,另一个问题是,是否有可能将整个模块更改为可以作为Windows服务运行的注册端点?目前我的sfb必须打开并登录…
请注意,这不是你发布的UCMA代码,它是Lync客户端SDK代码。
我将假设您想知道如何使用Lync Client SDK执行您的请求。
你需要钩住avmodal。ModalityStateChanged事件,以了解它何时更改为AVModality。状态变为已连接
一旦进入连接状态,你可以做你想做的。
调整你的代码我想到了:
private void StartConversationCallback(IAsyncResult asyncop)
{
// this is called once the dialing completes..
if (asyncop.IsCompleted == true)
{
ConversationWindow newConversationWindow = _automation.EndStartConversation(asyncop);
AVModality avModality = newConversationWindow.Conversation.Modalities[ModalityTypes.AudioVideo] as AVModality;
avModality.ModalityStateChanged += ConversationModalityStateChangedCallback;
}
}
private void ConversationModalityStateChangedCallback(object sender, ModalityStateChangedEventArgs e)
{
AVModality avModality = sender as AVModality;
if (avModality != null)
{
switch (e.NewState)
{
case ModalityState.Disconnected:
avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
break;
case ModalityState.Connected:
avModality.ModalityStateChanged -= ConversationModalityStateChangedCallback;
foreach (char c in "SOS")
{
avModality.AudioChannel.BeginSendDtmf(c.ToString(), null, null);
System.Threading.Thread.Sleep(300);
}
break;
}
}
}