From 5abaaa5353a63d4b8dedba2ab1697447a43d9cf8 Mon Sep 17 00:00:00 2001 From: sqozz Date: Tue, 1 Sep 2020 09:56:45 +0200 Subject: [PATCH] Improve answer/terminate error handling --- README.md | 3 ++- pylinphone.py | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bedf1a0..d08cd65 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Currently implemented Features: * check status for an registered account (`register-status` and `register-info`) * event-queue polling and onEvent functions (`pop-event`) * answer an incoming call (`accept`) +* terminate a running call (`terminate`) Features supported by the unix socket (linphone deamon): @@ -60,4 +61,4 @@ unregister |ALL version video [call_id] videosource cam|dummy [] -``` \ No newline at end of file +``` diff --git a/pylinphone.py b/pylinphone.py index 16631e8..5a79858 100644 --- a/pylinphone.py +++ b/pylinphone.py @@ -56,6 +56,18 @@ class LinphoneCommunicationSocket(): def answer(self, call_id=None): self.socket.send(("answer {call_id}".format(call_id="" if call_id == None else call_id)).encode("ascii")) answer = self._await_answer() + if answer["status"]: + return True + else: + raise RuntimeError(answer["error"]) + + def terminate(self, call_id=None): + self.socket.send(("terminate {call_id}".format(call_id="" if call_id == None else call_id)).encode("ascii")) + answer = self._await_answer() + if answer["status"]: + return True + else: + raise RuntimeError(answer["error"]) def process_event(self): self.socket.send("pop-event".encode("ascii"))