首页 文章

在手动客户端搜索之前,Lync 2013 SDK上的联系人状态/状态显示“状态未知”

提问于
浏览
2

我正在为lync开发一个自动化服务,它将根据用户的可用性/ lync“存在”自动将人们添加到IM对话中 . 它基本上列在一个列表中,检查谁在线,并将第一个人添加到呼叫中 .

我得到的问题是有时候(通常当lync必须重新启动时),它并不总是获取联系人的存在 .

首先,我让它 grab 了存在 . 然后我添加了代码以检查ContactInformationChanged事件触发,但除非我进入应用程序并手动键入我正在寻找的别名,否则这似乎不会发生 .

是否有一个我在某处丢失的Refresh()方法?或者有没有办法强迫它找到这个?这是我的搜索方法:

public Contact GetContact(string emailAddress)
    {
        Contact user;
        lock (ContactLookupCache)
        {
            while (!ContactLookupCache.TryGetValue(emailAddress.ToLower(), out user))
            {
                lock (Client)
                {
                    Client.ContactManager.BeginSearch(emailAddress, this.HandleContactLookup, null);
                }
                Monitor.Wait(ContactLookupCache);
            }
        }
        return user;
    }

 public string GetContactPresenceState(Contact contact)
        {            
            string presenceStatus = contact.GetContactInformation(ContactInformationType.Activity).ToString();
            // see if the status is either "Presence unknown" or "Updating..."
            if (IsUnknownPresenceState(presenceStatus))
            {
                lock (contact)
                {
                    //bug?? This event seems to only fire sometimes when you search on the app for contact details
                    contact.ContactInformationChanged += (object sender, ContactInformationChangedEventArgs e) =>
                    {
                        if (e.ChangedContactInformation.Contains(ContactInformationType.Activity))
                        {
                            lock (contact)
                            {
                                presenceStatus = contact.GetContactInformation(ContactInformationType.Activity).ToString();
                                if(!IsUnknownPresenceState(presenceStatus))
                                    Monitor.PulseAll(contact);
                            }
                        }
                    };
                    Monitor.Wait(contact);
                }
            }
            return presenceStatus;
        }

此外,抱歉蹩脚的代码...我只是想让它工作,并不断抛出更多的垃圾代码,希望有所帮助 .

1 回答

  • 0

    您是否可以验证代码是否适用于联系人列表中的所有联系人,而且只是没有列出未正确引发状态更改事件的联系人?

    这对我来说很有意义,因为你正在使用客户端SDK,它只会告诉你客户感兴趣的事件 . 例如,如果所有85,000个客户端都收到了公司其他85,000个客户端的状态变化,那么这将是非常流量密集的 .

    我认为你处于定期轮询存在或将联系人添加到客户端的领域(可能只是为了保持整洁而在相关组下) .

    如果不这样你可能想要查看比客户端SDK更适合集中服务的UCMA SDK .

相关问题