Pre-release
This release is a pre-release and may not be stable for production use.
RedFS - FreeSWITCH Event Socket
FreeSWITCH Event Socket Protocol Client Library by Python3:Gevent
Why RedFS ?
It's origin fork from greenswitch, with additional implementation:
- Minimalize dependency (gevent only)
- Large scale adaptation
- Bug fix
- Python3 syntax improvement
Usage
Installation
pip3 install redfs
FreeSWITCH configuration
event socket module
<configuration name="event_socket.conf" description="Socket Client">
<settings>
<param name="nat-map" value="false"/>
<param name="listen-ip" value="127.0.0.1"/>
<param name="listen-port" value="8021"/>
<param name="password" value="your-esl-password"/>
</settings>
</configuration>
dialplan
<include>
<context name="default">
<extension name="daemon-ex">
<condition regex="all">
<regex field="destination_number" expression="."/>
<action application="sched_hangup" data="+60 ALLOTTED_TIMEOUT"/>
<action application="park"/>
<anti-action application="hangup" data="REQUESTED_CHAN_UNAVAIL"/>
</condition>
</extension>
</context>
</include>
a simple python application for auto answer.
import gevent
import redfs
import traceback
ESL_HOST = '127.0.0.1'
ESL_PORT = 8021
ESL_PASSWORD = 'your-esl-password'
ESL_TIMEOUT = 10
def realtime(event):
event_name = event.headers.get('Event-Name')
uuid = event.headers.get('Unique-ID')
print(f'Event {event_name} with uuid {uuid}')
conn = redfs.InboundESL(host=ESL_HOST, port=ESL_PORT, password=ESL_PASSWORD, timeout=ESL_TIMEOUT)
conn.connect()
if event_name == 'CHANNEL_PARK':
cmd = f'api uuid_answer {uuid}'
res = conn.send(cmd)
print(cmd, res.data)
def printlog(event):
event_name = event.headers.get('Event-Name')
uuid = event.headers.get('Unique-ID')
print(f'Event {event_name} with uuid {uuid}')
cnx = redfs.InboundESL(host=ESL_HOST, port=ESL_PORT, password=ESL_PASSWORD, timeout=ESL_TIMEOUT)
cnx.connect()
cnx.register_handle(['CHANNEL_PARK', 'CHANNEL_ANSWER'], realtime)
cnx.register_handle('*', printlog)
cnx.send('EVENTS PLAIN ALL')
print('connected')
while True:
try:
gevent.sleep(1)
except KeyboardInterrupt:
cnx.stop()
break
except Exception as e:
print(e, traceback.format_exc())
Enjoy!
License
Metadata
Release files for redfs 0.0.4rc0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| redfs-0.0.4rc0.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| redfs-0.0.4rc0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.5 kB
Release files / redfs-0.0.4rc0.tar.gz
| Download URL | redfs-0.0.4rc0.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a350661e413b43fc3e3c60cfad30b300bd77e569952393f66d1aa37a0f9a336
|
|
BLAKE2b-256 checksum How to use checksums |
0aa5f33c3bee74ca00750c573553696d946d10571c19a144578ffc700bf92106
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|
Release files / redfs-0.0.4rc0-py3-none-any.whl
| Download URL | redfs-0.0.4rc0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
669ab77da59d40a82a7ff45b8415380a261e689cfe5ee156026ea7816ce9471d
|
|
BLAKE2b-256 checksum How to use checksums |
c57c3eaab9a2bff2cd0cc5aad5d6b29dfa09874bcf1a1f1979255b4a2390d795
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.6
|