Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
piphone-sip
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
4
Issues
4
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
La Quadrature du Net
piphone
piphone-sip
Commits
536c5932
Commit
536c5932
authored
Dec 07, 2016
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
ari.py
ari.py
+8
-3
piphone.py
piphone.py
+2
-9
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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