我正在尝试做的是一项功能,它将建议用户通过无线连接在office通信器中进行音频呼叫,而不是使用有线连接。
我一直在四处寻找,但没有找到我正在寻找的信息。
我正在寻找一种方法来检测Office Communicator是否处于音频呼叫中。有什么简单的方法可以做到这一点吗?
发布于 2011-04-20 17:56:33
我不认为你能用Communicator得到你想要的东西,但你可以接近它。(如果您要升级到Lync,您可能会更接近,或者一直走到那里)。
您需要使用Automation API - documentation here,下载here。
首先要尝试的是捕捉用户状态的变化:
MessengerClass _communicator;
public Form1()
{
InitializeComponent();
_communicator = new MessengerClass();
_communicator.OnMyStatusChange += new DMessengerEvents_OnMyStatusChangeEventHandler(_communicator_OnMyStatusChange);
}
void _communicator_OnMyStatusChange(int hr, MISTATUS mMyStatus)
{
AddText(string.Format("My Status changed to '{0}'", mMyStatus));
}您要查找的状态为MISTATUS_ON_THE_PHONE
这样做的缺点是某些状态将覆盖MISTATUS_ON_THE_PHONE状态。例如,如果用户设置为"Online",然后发出或接收呼叫,则状态将更改为MISTATUS_ON_THE_PHONE。但是,如果他们的状态设置为“请勿打扰”,并且他们拨打或接听电话,则状态不会更改为MISTATUS_ON_THE_PHONE。
您可以通过在创建调用时对其进行检查来解决此问题。捕获正在创建的新对话窗口相当简单:
_communicator = new MessengerClass();
_communicator.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(_communicator_OnIMWindowCreated);问题是,这将触发IM和AV会话,以及传入和传出的会话。无法直接检测呼叫是否是呼出的音频呼叫。
您还可以捕获“联系人已添加”事件,这将为您提供有关将哪些收件人添加到对话中以及何时添加的信息。发生这种情况的顺序可能会给你一些信息,比如它是传出的还是传入的,你可以查找"tel:“uri,告诉你这个呼叫是否是打给电话的(尽管这对通信器到通信器的呼叫没有帮助)。
_communicator.OnIMWindowContactAdded += new DMessengerEvents_OnIMWindowContactAddedEventHandler(_communicator_OnIMWindowContactAdded);最好的做法是对事件进行处理,看看在哪种情况下会发生什么。这段代码应该会让你上手并运行它。
MessengerClass _communicator;
public Form1()
{
InitializeComponent();
_communicator = new MessengerClass();
_communicator.OnIMWindowCreated += new DMessengerEvents_OnIMWindowCreatedEventHandler(_communicator_OnIMWindowCreated);
_communicator.OnIMWindowDestroyed += new DMessengerEvents_OnIMWindowDestroyedEventHandler(_communicator_OnIMWindowDestroyed);
_communicator.OnIMWindowContactAdded += new DMessengerEvents_OnIMWindowContactAddedEventHandler(_communicator_OnIMWindowContactAdded);
_communicator.OnIMWindowContactRemoved += new DMessengerEvents_OnIMWindowContactRemovedEventHandler(_communicator_OnIMWindowContactRemoved);
_communicator.OnMyStatusChange += new DMessengerEvents_OnMyStatusChangeEventHandler(_communicator_OnMyStatusChange);
}
void _communicator_OnMyStatusChange(int hr, MISTATUS mMyStatus)
{
AddText(string.Format("My Status changed to '{0}'", mMyStatus));
}
void _communicator_OnIMWindowContactRemoved(object pContact, object pIMWindow)
{
AddText(string.Format("{0} - Participant removed - '{1}'", ((IMessengerConversationWndAdvanced)pIMWindow).HWND, ((IMessengerContactAdvanced)pContact).SigninName));
}
void _communicator_OnIMWindowContactAdded(object pContact, object pIMWindow)
{
AddText(string.Format("{0} - Participant added - '{1}'", ((IMessengerConversationWndAdvanced)pIMWindow).HWND, ((IMessengerContactAdvanced)pContact).SigninName));
}
void _communicator_OnIMWindowDestroyed(object pIMWindow)
{
AddText(string.Format("{0} Conversation Closed, duration = {1}", ((IMessengerConversationWndAdvanced)pIMWindow).HWND, (DateTime.Now - _start).ToString()));
}
void _communicator_OnIMWindowCreated(object pIMWindow)
{
try
{
AddText(string.Format("{0} Conversation Created", ((IMessengerConversationWndAdvanced)pIMWindow).HWND));
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private delegate void AddTextDelegate(string text);
private void AddText(string text)
{
if (textBox1.InvokeRequired)
{
textBox1.Invoke(new AddTextDelegate(AddText), text);
return;
}
textBox1.Text += text + "\r\n";
}顺便说一句,如果你觉得有帮助的话,别忘了用"tick“来接受这个答案:)
https://stackoverflow.com/questions/5727570
复制相似问题