Search code examples
c#lyncucma

RemotePresenceView only receives one notification then nothing more happens


The PresenceView is created with an application endpoint which is manually provisioned. I have supplied it with three targets, which are all reporting "subscribed". But I only recieve the first notification. After that, nothing happens. The same is the case with polling. The NotificationRecieved event is not firing after the first notification. The Lync Event Log show no errors and no expections are thrown.

My setup is a virtual environment with a DC, Lync Server, and Developer machine which also acts as an application pool. Everything looks okay.

Below are some samples of my code. My solution consists of two projects: a small console application and a project with the lync code. It is based on the SubscribePresenceView sample solution from the UCMA code samples, which updates the presence state just fine, although it uses a user endpoint instead.

        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:[email protected]"));
        targets.Add(new RemotePresentitySubscriptionTarget("sip:[email protected]"));
        targets.Add(new RemotePresentitySubscriptionTarget("sip:[email protected]"));

        this.WireUpHandlersForView(_presenceView);

        _presenceView.StartSubscribingToPresentities(targets);
    }

Handle notification delegate method:

    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 + ".");
           }           
        }
    }

Please let me know if you need more information.


Solution

  • Never found a solution, so I went ahead and used a UserEndPoint instead, which works just fine.