目标是为模块开发系统监控解决方案的接口,该模块呼叫值班人员并从文件系统播放一些语音/音频文件。
我有一个skype for business 2015(fomerly lync)用户启用了手机选项。我也可以拨打电话号码。但问题是,如何等待被拨打的人接听电话并播放音频文件(或者更好的是System.Speech变体而不是播放音频文件),之后该人必须批准他/她接到了电话。
我现在拥有的东西:
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:\tmp\test1.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必须打开并登录..
答案 0 :(得分:0)
请注意,这不是您发布的UCMA代码,而是Lync Client SDK代码。
我将假设您想知道如何使用Lync Client SDK执行您所要求的操作。
您需要挂钩AVModality.ModalityStateChanged事件,以了解它何时更改为AVModality.State更改为Connected。
一旦处于连接状态,您就可以执行所需的操作。
调整你的代码我想出了:
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;
}
}
}