Skip to main content

Client implementation of FreeSWITCH Event Socket protocol with asyncio

Project description

What is Genesis?

Gitpod badge Tests badge Build badge License badge

Client implementation of FreeSWITCH Event Socket protocol with asyncio.

Inbound Socket Mode

In [1]: from genesis import Client

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

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

Event handler

With just one line of code we can make the function be called whenever we receive a certain event from the freeswitch.

Example

In [1]: from genesis import Client

In [2]: worker = Client("127.0.0.1", 8021, "ClueCon")

In [3]: async def handler(event):
   ...:     await asyncio.sleep(0.001)
   ...:     print(event)

In [4]: worker.on("HEARTBEAT", handler)

In [5]: await worker.connect()

Comments

  • For some cases where the ESL brings values without an associated key, we take the liberty of creating custom keys to simplify the work. Examples: X-API-Reply-Text and X-Event-Content-Text.
  • 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.

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.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

genesis-0.1.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: genesis-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for genesis-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9bf46dc00a8b1f3ba605290845b34b1dcb9ad2ba6d0f0d41b34aab4d67a41fb6
MD5 597559f1068d7408695ae0d742b02592
BLAKE2b-256 4a7864882c27ea91eef920f4e37b421b55c73484b08d5f5ca935dd6a78a72a01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: genesis-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for genesis-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21275ab64545f3200d6e6b2a5d50576a4f49a0754af068871bb86b4f1f2bc164
MD5 d039d80676e4418532ead28ef69a333a
BLAKE2b-256 41d3cd9d290bb06669e55e54dfa2c7afb7bd87eb15c09ddb859e3d1d12eb7d61

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