示例#1
0
        public void UnregisterAccount(Account account)
        {
            if (account.IsInUse)
            {
                throw new InvalidOperationException("Can't delete account as long as it's being used by other parties");
            }

            lock (_lock)
                if (_accounts.ContainsKey(account.Id))
                {
                    //TODO raise events for accounts being deleted
                    _provider.DeleteAccount(account.Id);
                    _accounts.Remove(account.Id);
                    account.SetId(-1);
                    try
                    {
                        if (account.IsLocal)
                        {
                            account.HandleStateChanged();
                        }
                    }
                    catch (ObjectDisposedException)
                    {
                        //tearing down
                    }
                }
        }
        public void UnregisterAccount(IAccountInternal account)
        {
            if (account.IsInUse)
            {
                throw new InvalidOperationException("Can't delete account as long as it's being used by other parties");
            }

            lock (_lock)
                if (_accounts.ContainsKey(account.Id))
                {
                    //if (account.IsRegistered)
                    //    Helper.GuardError(PJSUA_DLL.Accounts.pjsua_acc_set_registration(account.Id, false));

                    //_deleting.Enqueue(account);//TODO raise events for accounts being deleted
                    _provider.DeleteAccount(account.Id);
                    _accounts.Remove(account.Id);
                    account.SetId(-1);
                    if (account.IsLocal)
                    {
                        account.HandleStateChanged();
                    }
                    account.InternalDispose();
                }
        }