/// <summary> /// Gets the LoginSession object for the provided accountId, creating one if necessary /// </summary> /// <param name="accountId">the AccountId</param> /// <returns>the login session for that accountId</returns> /// <exception cref="ArgumentNullException">thrown when accountId is null or empty</exception> /// <remarks>If a new LoginSession is created, LoginSessions.AfterKeyAdded will be raised.</remarks> public ILoginSession GetLoginSession(AccountId accountId) { if (AccountId.IsNullOrEmpty(accountId)) { throw new ArgumentNullException(nameof(accountId)); } CheckInitialized(); if (_loginSessions.ContainsKey(accountId)) { return(_loginSessions[accountId]); } var loginSession = new LoginSession(this, accountId); _loginSessions[accountId] = loginSession; loginSession.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args) { if (args.PropertyName != nameof(loginSession.State)) { return; } if (loginSession.State == LoginState.LoggedOut) { _loginSessions.Remove(accountId); } }; return(loginSession); }
public IAsyncResult BeginRemovePresenceSubscription(AccountId userId, AsyncCallback callback) { AssertLoggedIn(); AsyncNoResult ar = new AsyncNoResult(callback); if (!_presenceSubscriptions.ContainsKey((userId))) { ar.SetCompletedSynchronously(); return(ar); } var request = new vx_req_account_buddy_delete_t(); request.account_handle = _accountHandle; request.buddy_uri = userId.ToString(); VxClient.Instance.BeginIssueRequest(request, result => { try { VxClient.Instance.EndIssueRequest(result); _presenceSubscriptions.Remove(userId); ar.SetComplete(); } catch (Exception e) { VivoxDebug.Instance.VxExceptionMessage($"{request.GetType().Name} failed: {e}"); ar.SetComplete(e); if (VivoxDebug.Instance.throwInternalExcepetions) { throw; } return; } }); return(ar); }
public void UpdateLocation(string uriWithTag, PresenceStatus status, string message) { PresenceLocation item; if (!_locations.ContainsKey(uriWithTag)) { if (status != PresenceStatus.Unavailable) { item = new PresenceLocation(uriWithTag) { CurrentPresence = new Presence(status, message), Subscription = this }; _locations[item.Key] = item; } } else { item = (PresenceLocation)_locations[uriWithTag]; item.CurrentPresence = new Presence(status, message); if (status == PresenceStatus.Unavailable) { _locations.Remove(uriWithTag); } } }
public void DeleteChannelSession(ChannelId channelId) { if (_channelSessions.ContainsKey(channelId)) { (_channelSessions[channelId] as ChannelSession)?.Delete(); _channelSessions.Remove(channelId); } }
private void HandleParticipantRemoved(vx_evt_base_t eventMessage) { vx_evt_participant_removed_t evt = eventMessage; Debug.Assert(evt != null); if (evt.session_handle != _sessionHandle) { return; } _participants.Remove(evt.participant_uri); }