Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
piphone
piphone-sip
Commits
536c5932
Commit
536c5932
authored
Dec 07, 2016
by
okhin
Browse files
Fixing the infinite loop and status of the calls, it works!
parent
c408af90
Pipeline
#623
passed with stage
in 1 second
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
ari.py
View file @
536c5932
...
...
@@ -19,6 +19,8 @@ def ari_call(config, verbs, method, payload):
payload
[
'app'
]
=
config
[
'app'
]
payload
[
'api_key'
]
=
config
[
'key'
]
+
':'
+
config
[
'password'
]
result
=
call
(
full_url
,
data
=
payload
)
print
(
full_url
)
print
(
payload
)
result
.
raise_for_status
()
if
method
.
lower
()
==
'post'
:
# We need to test if we have something in the object, to eventually return it
...
...
@@ -26,7 +28,10 @@ def ari_call(config, verbs, method, payload):
return
result
.
json
()
except
:
result
=
requests
.
get
(
full_url
,
data
=
payload
)
return
result
.
json
()
try
:
return
result
.
json
()
except
:
return
'{}'
except
:
raise
...
...
@@ -34,7 +39,7 @@ class Bridge(object):
'''
This is a bridge object, we use it to manage various needed calls
'''
def
__init__
(
self
,
config
,
name
,
mode
):
def
__init__
(
self
,
config
,
name
,
mode
=
'mixing'
):
self
.
name
=
name
self
.
config
=
config
self
.
mode
=
mode
...
...
@@ -142,6 +147,6 @@ class Playback(object):
Let's stop a specific playback
'''
try
:
return
ari_call
(
self
.
config
,
[
'playbacks'
,
self
.
name
],
'DEL'
,
{})
ari_call
(
self
.
config
,
[
'playbacks'
,
self
.
name
],
'DEL'
,
{})
except
:
raise
piphone.py
View file @
536c5932
...
...
@@ -228,7 +228,6 @@ class Call(object):
else
:
self
.
id
=
callid
self
.
db
=
db
self
.
event_handler
({
'type'
:
'Created'
,
'timestamp'
:
datetime
.
datetime
.
now
().
isoformat
(),
'channel'
:
{
'id'
:
'Init'
}})
except
Exception
as
e
:
phone_logger
.
exception
(
e
)
raise
e
...
...
@@ -269,13 +268,6 @@ class Call(object):
There's a new event related to our call
'''
state
=
event
[
'type'
]
try
:
if
self
.
state
.
startswith
(
state
):
# We're alreaydy in this state, we just need to noop
return
except
IndexError
:
if
state
in
self
.
actions
:
getattr
(
self
,
self
.
actions
[
state
])(
event
=
event
)
if
state
in
self
.
actions
:
getattr
(
self
,
self
.
actions
[
state
])(
event
=
event
)
...
...
@@ -346,7 +338,7 @@ class Call(object):
bridge
.
create
()
# Step 2, moving channels
channels
=
","
.
join
([
self
.
id
+
'-'
+
self
.
caller
,
self
.
id
+
'-'
+
self
.
callee
])
phone_logger
.
debug
(
"Moving channels to the created bridge: {}"
.
format
(
br
o
dge
.
name
,))
phone_logger
.
debug
(
"Moving channels to the created bridge: {}"
.
format
(
br
i
dge
.
name
,))
bridge
.
addChannel
(
channels
)
phone_logger
.
info
(
"Call now fully connected: {} <-> {}"
.
format
(
self
.
caller
,
self
.
callee
))
return
...
...
@@ -469,6 +461,7 @@ def originate(db, callid=None):
else
:
call
=
Call
(
request
.
params
[
'caller'
],
request
.
params
[
'callee'
],
request
.
params
[
'api'
],
db
=
db
)
bottle_logger
.
debug
(
"Originate a call: {}"
.
format
(
json
.
dumps
(
call
,
cls
=
PiphoneJSONEncoder
)))
call
.
event_handler
({
'type'
:
'Created'
,
'timestamp'
:
datetime
.
datetime
.
now
().
isoformat
(),
'channel'
:
{
'id'
:
'Init'
}})
call
.
save
()
head
=
{
'call'
:
call
.
url
,
'user'
:
request
.
params
[
'api'
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment