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: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);
    }

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.

有帮助吗?

解决方案

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

其他提示

I realise this quite old now, but I've had exactly the same issue recently, so it might be worth answering.

The reason, in my case, was that the server could not establish a connection back to the application endpoint. I can't see anything wrong with the code here, so it's most likely a firewall or routing issue between the two machines.

On setting up your application endpoint, you define a port, and that port needs to be accessible on the machine hosting the application endpoint (Your developer machine in this case).

  • When you establish the application endpoint, it opens a connection to the server (typically port 5061, I think).
  • When you subscribe to the RemotePresenceView it sends that subscription request down that connection, and the server will respond with notifications of the current state of all subscribed Presentities (a silly word) on that same connection, which is why you get the first notification.
  • For all subsequent notifications the server will attempt to connect back to your application endpoint host machine on the port you have defined for the endpoint and this is probably where the problem is.

For user endpoints, you're not expected to have a port open, so the server will just send notifications down the client's connection to the server, so that's why that works.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top