Skip to main content

Client implementation of FreeSWITCH Event Socket protocol with asyncio

Project description

What is Genesis?

Client implementation of FreeSWITCH Event Socket protocol with asyncio.

Gitpod badge Tests badge Build badge License badge Pypi Version badge Pypi python version badge Pypi wheel badge

Inbound Socket Mode

In [1]: from genesis import Inbound

In [2]: async with Inbound("127.0.0.1", 8021, "ClueCon") as client:
            response = await client.send("uptime")

In [3]: print(response)
{'Content-Type': 'command/reply', 'Reply-Text': '6943047'}

Incoming Event handler

In [1]: from genesis import Consumer

In [2]: app = Consumer("127.0.0.1", 8021, "ClueCon")

In [3]:  @app.handle("HEARTBEAT")
   ...:  async def handler(event):
   ...:     await asyncio.sleep(0.001)
   ...:     print(event)

In [4]: await app.start()

Outbound Socket Mode

XML dialplan example

<extension name="out socket">
   <condition>
      <action application="socket" data="127.0.0.1:5000 async full"/>
   </condition>
</extension>

Python application code

In [1]: from genesis import Outbound

In [2]: async def handler(session):
   ...:     await session.answer()
   ...:     await session.playback('ivr/ivr-welcome')
   ...:     await session.hangup()


In [3]: app = Outbound("127.0.0.1", 5000, handler)

In [4]: await app.start()

Comments

  • For simplify event object strtucuture, we decide work with dicts to store event headers. For events with body, your content is stored in some object, with X-Event-Content key.
  • If a key purposely repeats in an event (Example: Content-Length in BACKGROUND_JOB event), we store both values in a list, in the order they are received.
  • For practical reasons, every event handler should be awaitable.

What is FreeSwitch?

FreeSWITCH is a free and open-source application server for real-time communication, WebRTC, telecommunications, video and Voice over Internet Protocol (VoIP). Multiplatform, it runs on Linux, Windows, macOS and FreeBSD. It is used to build PBX systems, IVR services, videoconferencing with chat and screen sharing, wholesale least-cost routing, Session Border Controller (SBC) and embedded communication appliances. It has full support for encryption, ZRTP, DTLS, SIPS. It can act as a gateway between PSTN, SIP, WebRTC, and many other communication protocols. Its core library, libfreeswitch, can be embedded into other projects. It is licensed under the Mozilla Public License (MPL), a free software license.

By wikipedia.

What is ESL?

ESL is a way to communicate with FreeSwitch. See more details here.

Why asyncio?

Asynchronous programming is a type of parallel programming in which a unit of work is allowed to run separately from the primary application thread. When the work is complete, it notifies the main thread about completion or failure of the worker thread. There are numerous benefits to using it, such as improved application performance and enhanced responsiveness. We adopted this way of working, as integrating genesis with other applications is simpler, since you only need to deal with python's native asynchronous programming interface.

How to contribute?

If you are thinking of contributing in any way to the project, you will be very welcome. Whether it's improving existing documentation, suggesting new features or running existing bugs, it's only by working together that the project will grow.

Do not forget to see our Contributing Guide and our Code of Conduct to always be aligned with the ideas of the project.

Contributors

Will be welcome ❤️

Author


@Otoru

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

genesis-0.3.1.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

genesis-0.3.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file genesis-0.3.1.tar.gz.

File metadata

  • Download URL: genesis-0.3.1.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for genesis-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fd4d110afdc2b9f0e8d5b88be5d54cda2a1df72283440deac30a6e8851ad35fd
MD5 23242f9d83ae6ec51a57d558ddc8dc49
BLAKE2b-256 d138d1a9fc5e62c77ae2853f7b675152dac8c53766166ad61534d61a58baeac2

See more details on using hashes here.

File details

Details for the file genesis-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: genesis-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for genesis-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 273d54546afdd74efecec213ccb61b7ae401197c74fbb942e0e9c7e44cd49ca8
MD5 ee1436e4f7fd329a04324949ab0429ea
BLAKE2b-256 79e91cc3d87b26e1027a5f8ef0316f30897378abba5fe64076fd36eb7f3d0edc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page