public void RegisterAccount(IAccountInternal account, bool @default) { Helper.GuardNotNull(account); lock (_lock) { if (account.Transport == null) { account.SetTransport(_localRegistry.SipTransport); } int id = -1; if (account.IsLocal) { id = _provider.AddLocalAccountAndGetId(_localRegistry.SipTransport.Id, @default); } else { id = _provider.AddAccountAndGetId(account.Config, @default); } account.SetId(id); _accounts.Add(account.Id, account); account.HandleStateChanged(); } }
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(); } }
public void RegisterAccount(IAccountInternal account, bool @default) { Helper.GuardNotNull(account); lock (_lock) { if (account.Transport == null) account.SetTransport(_localRegistry.SipTransport); int id = -1; if (account.IsLocal) id = _provider.AddLocalAccountAndGetId(_localRegistry.SipTransport.Id, @default); else id = _provider.AddAccountAndGetId(account.Config, @default); account.SetId(id); _accounts.Add(account.Id, account); account.HandleStateChanged(); } }
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(); } }