Fix status parsing
The get_status method now parses the output from linphone more dynamically. This allows to fetch status information while in different states of a call (ringing, call established, etc).
This commit is contained in:
parent
7e28f36dc3
commit
b4b1ba31dc
|
@ -109,12 +109,10 @@ class LinphoneCommunicationSocket():
|
||||||
answer = self.send_command("call-status {call_id}".format(call_id=call_id))
|
answer = self.send_command("call-status {call_id}".format(call_id=call_id))
|
||||||
if answer["status"]:
|
if answer["status"]:
|
||||||
data = answer["data"]
|
data = answer["data"]
|
||||||
status = {
|
status = {}
|
||||||
"state": data[0].split(":", 1)[1].strip(),
|
for line in data:
|
||||||
"from": data[1].split(":", 1)[1].strip(),
|
key, value = line.split(":", 1)
|
||||||
"direction": data[2].split(":", 1)[1].strip(),
|
status[key.strip().lower()] = value.strip()
|
||||||
"duration": int(data[3].split(":", 1)[1].strip())
|
|
||||||
}
|
|
||||||
return status
|
return status
|
||||||
else:
|
else:
|
||||||
raise RuntimeError(answer["error"])
|
raise RuntimeError(answer["error"])
|
||||||
|
|
Loading…
Reference in a new issue