Question

In a Trusted Application Endpoint I have to publish users states based on en external presence provider, and I can do that (clearing them later when the external source goes "Idle" is a different problem)

What is a problem though is that if I publish a new state for User A, that is not reflected on that users own Lync Client, though everybody else get the updates.

At this moment I'm using this snippet of code to do the publishing:

    user.Endpoint.LocalOwnerPresence.BeginPublishPresence(
        user.categories,
        arBeginPublishPresence =>
        {
            try
            {
                user.Endpoint.PresenceServices.EndUpdatePresenceState(arBeginPublishPresence);
                logger.log("Published presence for {0} with state {1}.", user.SipUserUri, newState.Availability);
            }
            catch (RealTimeException ex)
            {
                logger.log("Failed publishing presence for {0}. {1}", user.SipUserUri, ex);
            }
        },
        null);

Where user.categories is:

            PresenceCategoryWithMetaData stateWithMetaDataForPersonal = new PresenceCategoryWithMetaData(++instanceId, 400, newState);
            PresenceCategoryWithMetaData stateWithMetaDataForWorkgroup = new PresenceCategoryWithMetaData(instanceId, 300, newState);
            PresenceCategoryWithMetaData stateWithMetaDataForColleagues = new PresenceCategoryWithMetaData(instanceId, 200, newState);
            PresenceCategoryWithMetaData stateWithMetaDataForExternal = new PresenceCategoryWithMetaData(instanceId, 100, newState);
            PresenceCategoryWithMetaData stateWithMetaDataForAll = new PresenceCategoryWithMetaData(instanceId, 0, newState);
            if (instanceId >= Int64.MaxValue)
            {
                instanceId = 1;
            }

            stateWithMetaDataForPersonal.ExpiryPolicy = expirypolicy;
            stateWithMetaDataForWorkgroup.ExpiryPolicy = expirypolicy;
            stateWithMetaDataForColleagues.ExpiryPolicy = expirypolicy;
            stateWithMetaDataForExternal.ExpiryPolicy = expirypolicy;
            stateWithMetaDataForAll.ExpiryPolicy = expirypolicy;

            stateWithMetaDataForPersonal.Expires = timeout;
            stateWithMetaDataForWorkgroup.Expires = timeout;
            stateWithMetaDataForColleagues.Expires = timeout;
            stateWithMetaDataForExternal.Expires = timeout;
            stateWithMetaDataForAll.Expires = timeout;

            user.categories =
                new List<PresenceCategoryWithMetaData>()
                        {
                            stateWithMetaDataForPersonal,
                            stateWithMetaDataForWorkgroup,
                            stateWithMetaDataForColleagues,
                            stateWithMetaDataForExternal,
                            stateWithMetaDataForAll
                        };

The categories are carpet bombing the presence state, and I just know I'm doing it wrong. It can not possible be this ... messy.

Please bear with me, I'm new to C#, .NET and UCMA, never touched any of it till a month ago.

Was it helpful?

Solution

This seems like the right behaviour to me. Lync will aggregate presence across ALL endpoints that the user is signed in on, to give a single presence state. For example, if the user is signed in to Lync on his PC with his presence set to "Away", and also on his mobile client with a presence of "Available", then all users will see an aggregated presence of "Available" - because he is available to reach on one of the endpoints. However, his Lync client will still be "Away".

So I think the same thing is happening for you. Your UCMA app is just another endpoint that you're publishing presence from. You may be publishing a presence of "Available", but it is presence from the endpoint in the UMCA app, so it won't affect any other endpoints he's signed in on, e.g. the Lync client. However, all other users will see the aggregated presence state.

This is more of an educated guess than anything I've proven with code. I've had a scout through the SDK, but I can't see any way to "override" the other endpoint's presence (and actually, doing that strongly feels like the wrong behaviour).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top