Exemple #1
0
 public void UpdatePresence(bool ignoreLoginState = false)
 {
     if ((ignoreLoginState && _appContext.ConnectionManager.Connection.isEstablished()) || _appContext.ConnectionManager.IsOnline())
     {
         PresenceChangeRq request = new PresenceChangeRq()
             {
                 presence = new PresenceElement()
                     {
                         mode = _currentUserPresence.Mode.ToString(),
                         type = _currentUserPresence.Type.ToString(),
                         priority = _currentUserPresence.Priority,
                         status = _currentUserPresence.Status
                     },
                 shortCode = ActiveShortCode,
                 user = _currentUser.Username
             };
         try
         {
             _appContext.ConnectionManager.Connection.RequestAsync<PresenceChangeRq,PresenceChangeRs>(request, HandlePresenceUpdateResponse);
         }
         catch (Exception e)
         {
             Logger.Error("Failed to update presence : " + e.Message,e);
         }
     }
 }
Exemple #2
0
 internal void ProcessPresenceChange(PresenceChangeRq request)
 {
     if (_haveRoster)
     {
         ChangePresence(request.user,
             new Presence(request.resource, request.presence, request.shortCode)
             {
                 ClientInfo = new ClientInfo()
                 {
                     Platform = request.clientInfo == null ? null : request.clientInfo.platform,
                     Version = request.clientInfo == null ? null : request.clientInfo.version
                 }
             }
             );
     }
     else
     {
         _queuedPresenceChanges.Enqueue(request);
     }
 }
Exemple #3
0
 private void HandlePresenceUpdateResponse(PresenceChangeRq presenceChangeRq, PresenceChangeRs presenceChangeRs, Exception ex)
 {
     if(ex == null)
     {
         Logger.Debug("Successfully updated presence : " + _currentUserPresence);
     } else
     {
         Logger.Error("Failed to update presence : " + ex.Message, ex);
     }
 }