Beispiel #1
0
        /// <summary>
        /// Set presence information for a particular user. Only the following states can be set:
        /// AVAILABLE, BUSY, ON_THE_PHONE, AWAY. Attempts to set other states will result in a
        /// 403 FORBIDDEN response. The UNDEFINED value is an error case used to represent the
        /// case if the value stored in the system cannot be represented by the values known to the
        /// API. The other states are reserved for future use.
        /// </summary>
        /// <param name="uid">User ID.</param>
        /// <param name="presence">The user's presence.</param>
        /// <returns>The user's new presence.</returns>
        public Presence SetPresence(Presence presence)
        {
            var symphonyPresence = CreateSymphonyPresence(presence);
            var result           = _apiExecutor.Execute(_presenceApi.V1UserUidPresencePost, (long?)presence.UserId, _authTokens.SessionToken, symphonyPresence);

            return(PresenceFactory.Create(presence.UserId, result));
        }
Beispiel #2
0
 /// <summary>
 /// Get presence information about a particular user.
 /// </summary>
 /// <param name="uid">User ID.</param>
 /// <returns>The presence for the user.</returns>
 public Presence GetPresence(long uid)
 {
     try
     {
         var presence = _apiExecutor.Execute(_userApi.V1PresenceGet2Async, uid, _authTokens.SessionToken);
         return(PresenceFactory.Create(uid, presence));
     }
     catch (Exception e)
     {
         _log?.LogError(0, e, "An error has occured while trying to retrieve presence information from user {uid}", uid);
         throw;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Get presence information about all company (pod) users. The returned data
        /// is taken from the in-memory cache for performance reasons which means inactive
        /// users may be omitted from the response. All non-inactive users WILL be returned
        /// and some inactive users MAY be included. Any omitted user IS inactive.
        /// </summary>
        /// <returns>List of presences.</returns>
        public List <Presence> GetPresences()
        {
            var presences = _apiExecutor.Execute(_presenceApi.V1Async, _authTokens.SessionToken);
            var result    = new List <Presence>();

            if (presences != null)
            {
                foreach (var presence in presences)
                {
                    result.Add(PresenceFactory.Create(presence));
                }
            }
            return(result);
        }
Beispiel #4
0
 /// <summary>
 /// Set presence information for a particular user. Only the following states can be set:
 /// AVAILABLE, BUSY, ON_THE_PHONE, AWAY. Attempts to set other states will result in a
 /// 403 FORBIDDEN response. The UNDEFINED value is an error case used to represent the
 /// case if the value stored in the system cannot be represented by the values known to the
 /// API. The other states are reserved for future use.
 /// </summary>
 /// <param name="uid">User ID.</param>
 /// <param name="presence">The user's presence.</param>
 /// <returns>The user's new presence.</returns>
 public Presence SetPresence(Presence presence)
 {
     try
     {
         var symphonyPresence = CreateSymphonyPresence(presence);
         //var result = _apiExecutor.Execute(_presenceApi.V1UserUidPresencePost, (long?)presence.UserId, _authTokens.SessionToken, symphonyPresence);
         var result = _apiExecutor.Execute(_userApi.V1PresencePost2Async, presence.UserId,
                                           _authTokens.SessionToken, symphonyPresence);
         return(PresenceFactory.Create(presence.UserId, result));
     }
     catch (Exception e)
     {
         var userId = presence.UserId;
         _log?.LogError(0, e, "An error has occured while trying to set the presence of user {userId}", userId);
         throw;
     }
 }
Beispiel #5
0
        /// <summary>
        /// Get presence information about a particular user.
        /// </summary>
        /// <param name="uid">User ID.</param>
        /// <returns>The presence for the user.</returns>
        public Presence GetPresence(long uid)
        {
            var presence = _apiExecutor.Execute(_presenceApi.V1UserUidPresenceGet, (long?)uid, _authTokens.SessionToken);

            return(PresenceFactory.Create(uid, presence));
        }
Beispiel #6
0
 public PresenceManager(IZone zone, PresenceFactory presenceFactory, IPresenceConfigurationReader configurationReader)
 {
     _zone                = zone;
     _presenceFactory     = presenceFactory;
     _configurationReader = configurationReader;
 }