PresenceView 是使用手动配置的应用程序端点创建的。我为它提供了三个目标,它们都报告“订阅”。但我只收到第一个通知。之后,什么也没有发生。轮询也是如此。NotificationRecieved 事件在第一次通知后未触发。Lync 事件日志显示没有错误,也没有引发任何期望。
我的设置是一个带有 DC、Lync Server 和 Developer 机器的虚拟环境,它也充当应用程序池。一切看起来都很好。
以下是我的一些代码示例。我的解决方案包含两个项目:一个小型控制台应用程序和一个带有 lync 代码的项目。它基于 UCMA 代码示例中的 SubscribePresenceView 示例解决方案,它可以很好地更新存在状态,尽管它使用的是用户端点。
public void Run()
{
_helper = new Helper(new ConsoleLogger());
_applicationEndpoint = _helper.CreateApplicationEndpoint();
var viewSettings = new RemotePresenceViewSettings();
viewSettings.SubscriptionMode = RemotePresenceViewSubscriptionMode.Default;
_presenceView = new RemotePresenceView(_applicationEndpoint, viewSettings);
List<RemotePresentitySubscriptionTarget> targets = new List<RemotePresentitySubscriptionTarget>();
targets.Add(new RemotePresentitySubscriptionTarget("sip:mortenl@mupersan.local"));
targets.Add(new RemotePresentitySubscriptionTarget("sip:finnl@mupersan.local"));
targets.Add(new RemotePresentitySubscriptionTarget("sip:andersl@mupersan.local"));
this.WireUpHandlersForView(_presenceView);
_presenceView.StartSubscribingToPresentities(targets);
}
处理通知委托方法:
private void RemotePresenceView_NotificationReceived(object sender, RemotePresentitiesNotificationEventArgs e)
{
// A RemotePresentityNotification will contain all the
// categories for one user; Notifications can contain notifications
// for multiple users.
foreach (RemotePresentityNotification notification in e.Notifications)
{
Console.WriteLine("\nReceived a Notification for user "+ notification.PresentityUri + ".");
// If a category on notification is null, the category
// was not present in the notification. This means there were no
// changes in that category.
if (notification.AggregatedPresenceState != null)
{
Console.WriteLine("Aggregate State = " + notification.AggregatedPresenceState.Availability + ".");
}
if (notification.PersonalNote != null)
{
Console.WriteLine("PersonalNote: " + notification.PersonalNote.Message + ".");
}
if (notification.ContactCard != null)
{
// A ContactCard contains many properties; only display
// some.
ContactCard contactCard = notification.ContactCard;
Console.WriteLine("ContactCard Company: " + contactCard.Company + ".");
Console.WriteLine("ContactCard DisplayName: " + contactCard.DisplayName + ".");
Console.WriteLine("ContactCard EmailAddress: " + contactCard.EmailAddress + ".");
}
}
}
如果您需要更多信息,请告诉我。