Quantcast
Channel: Microsoft Unified Communications Managed API SDK forum
Viewing all articles
Browse latest Browse all 889

UCMA 4.0 how to "PresenceServices.BeginPresenceQuery"

$
0
0

Hello i been struggling a couple of hours trying to figure out how to get a list of users and their presence.

this is what i have right now:

private List<string> GetOperatorsPresence(List<string> sipTargets, ApplicationEndpoint appEndPoint)
        {
            appEndPoint.PresenceServices.BeginPresenceQuery(
                sipTargets, new string[] { "state" },
                null, // EndGetFreeOperator
                result =>
                {
                    try
                    {
                        // Retrieve the results of the query.
                        IEnumerable<RemotePresentityNotification> notifications = appEndPoint.PresenceServices.EndPresenceQuery(result);


                        operatorAvailableList = new List<string>();

                        foreach (RemotePresentityNotification notification in notifications)
                        {
                            long v = notification.AggregatedPresenceState.AvailabilityValue;
                            if (v >= 3000 && v <= 4499)
                            {
                                //online
                                operatorAvailableList.Add(notification.PresentityUri);
                            }
                            else if (v >= 4500 && v <= 5999)
                            {
                                //idle online
                                operatorAvailableList.Add(notification.PresentityUri);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Helper.Logger.Error(ex.ToString());
                    }
                },
                null);

            waitForOperatorList.WaitOne();

            return operatorAvailableList;
        }

But... is not working at all i think is is in some kind of endless loop :(

Could someone explain me how to use this method with a callback (not the event handler version) Thank you!


If you do not understand me try Spanish :)



Viewing all articles
Browse latest Browse all 889

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>