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
2605258b
Commit
2605258b
authored
May 09, 2016
by
okhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding the delete/hangup channel system
parent
cf0a3d05
Pipeline
#27
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
1 deletion
+35
-1
ari.py
ari.py
+10
-0
piphone.py
piphone.py
+25
-1
No files found.
ari.py
View file @
2605258b
...
...
@@ -111,6 +111,16 @@ class Channel(object):
return
ari_call
(
self
.
config
,
[
'channels'
,
self
.
name
,
'play'
,
playback_id
],
'POST'
,
{
'media'
:
media
,
'lang'
:
lang
})
except
:
raise
def
delete
(
self
):
'''
Delete the channel (hangup)
'''
try
:
return
ari_call
(
self
.
config
,
[
'channels'
,
self
.
name
],
'DEL'
,
{})
except
:
raise
class
Playback
(
object
):
'''
This object is used to manage ARI calls for playbacks.
...
...
piphone.py
View file @
2605258b
...
...
@@ -211,7 +211,8 @@ class Call(object):
history
=
[]
actions
=
{
'Created'
:
'call_caller'
,
'ChannelStateChange'
:
'change'
,
'ChannelDtmfReceived'
:
'dtmf'
}
,
'ChannelDtmfReceived'
:
'dtmf'
,
'Hangup'
:
'hangup'
}
def
__init__
(
self
,
caller
,
callee
,
owner
,
callid
=
None
,
db
=
None
):
try
:
...
...
@@ -266,6 +267,29 @@ class Call(object):
if
state
in
self
.
actions
:
getattr
(
self
,
self
.
actions
[
state
])(
event
=
event
)
def
hangup
(
self
,
event
):
'''
There's a call which has lost connection. Probably someone who hanged up the call.
We need to check if the other side is still up, which can be done by checking
the bridge item (it is in the channels part of the bridge object) and see if there's
more than one channel.
If there's more than one, then we need to send a hangup to the other side and then delete
our channel, if not we need to delete ourselves and then delete the bridge.
'''
bridge_id
=
'-'
.
join
(
event
[
'channel'
][
'id'
].
split
(
'-'
)[:
-
1
])
bridge
=
ari
.
Bridge
(
config
[
'asterisk'
],
bridge_id
,
'mixed'
)
results
=
json
.
loads
(
bridge
.
status
())
if
len
(
results
[
'channels'
])
==
0
:
# We were the last channel standing
phone_logger
.
info
(
'Deleting bridge {}'
.
format
(
bridge_id
))
bridge
.
delete
()
else
:
# There's at least one channel standing
for
channel
in
results
[
'channels'
]:
chan
=
ari
.
Channel
(
config
[
'asterisk'
],
channel
)
phone_logger
.
info
(
'Hanging up channel {}'
.
format
(
channel
))
chan
.
delete
()
def
dtmf
(
self
,
event
):
'''
We received a DTMF sequence
...
...
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