Add unregister function

This commit is contained in:
sqozz 2021-02-25 10:33:32 +01:00
parent beb544b3b6
commit 81f2b1695f
2 changed files with 9 additions and 0 deletions

View file

@ -13,6 +13,7 @@ Currently implemented Features:
* play dtmf tones (`dtmf`) * play dtmf tones (`dtmf`)
* get call status (`call-status`) * get call status (`call-status`)
* get call stats (`call-stats`) * get call stats (`call-stats`)
* unregister an account (`unregister`)
Features supported by the unix socket (linphone deamon): Features supported by the unix socket (linphone deamon):

View file

@ -28,6 +28,14 @@ class LinphoneCommunicationSocket():
answer = self.send_command(("register {identity} {proxy_address} {password} {userid} {realm} {parameters}".format(identity=identity, proxy_address=proxy_address, password=password, userid=userid, realm=realm, parameters="" if parameters else parameters))) answer = self.send_command(("register {identity} {proxy_address} {password} {userid} {realm} {parameters}".format(identity=identity, proxy_address=proxy_address, password=password, userid=userid, realm=realm, parameters="" if parameters else parameters)))
return int(answer["data"][0].split(":", 1)[1].strip()) #id of newly registered account return int(answer["data"][0].split(":", 1)[1].strip()) #id of newly registered account
def unregister(self, register_id):
self.send_command("unregister {register_id}".format(register_id=register_id))
if answer["status"]:
return True
else:
raise RuntimeError(answer["error"])
def register_status(self, account_id=None): def register_status(self, account_id=None):
answer = self.send_command(("register-status {account_id}".format(account_id="ALL" if account_id == None else account_id))) answer = self.send_command(("register-status {account_id}".format(account_id="ALL" if account_id == None else account_id)))
accounts = [] accounts = []