Metadata-Version: 2.1
Name: trio-engineio
Version: 0.1.0
Summary: An asynchronous Engine.IO client using the trio framework
Home-page: https://github.com/Elmeric/trio-engineio
License: BSD-3-Clause
Author: Eric Lemoine
Author-email: erik.lemoine@gmail.com
Requires-Python: >=3.7.2,<4.0.0
Classifier: Environment :: Web Environment
Classifier: Framework :: Trio
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: httpcore (>=0.16.0,<0.17.0)
Requires-Dist: trio (>=0.22.0,<0.23.0)
Requires-Dist: trio-websocket (>=0.9.2,<0.10.0)
Requires-Dist: typing-extensions (>=4.4.0,<5.0.0); python_version < "3.8"
Project-URL: Repository, https://github.com/Elmeric/trio-engineio
Description-Content-Type: text/markdown


# Trio-Engine.IO

[![python](https://img.shields.io/badge/python-3.7%2B-blue)](https://github.com/Elmeric/trio-engineio)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Tests](https://github.com/Elmeric/trio-engineio/actions/workflows/test.yml/badge.svg)](https://github.com/Elmeric/trio-engineio/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/Elmeric/trio-engineio/badge.svg)](https://coveralls.io/github/Elmeric/trio-engineio)
[![license](https://img.shields.io/badge/license-BSD--3--Clause-green)](https://github.com/Elmeric/trio-engineio/blob/master/LICENSE)

An asynchronous **[Engine.IO](https://github.com/socketio/engine.io-protocol/tree/v3)** client using the [`trio`](https://trio.readthedocs/en/latest) framework.

Only the revision **3** of the Engine.IO protocol is supported.

## Requirements

- Python 3.7+
- [`trio`](https://trio.readthedocs.io/)
- [`httpcore`](https://www.encode.io/httpcore/)
- [`trio-websocket`](https://trio-websocket.readthedocs.io/)

## Usage

```Python
import trio

from trio_engineio.trio_client import EngineIoClient, EngineIoConnectionError


def on_connect():
    print(f"***** Connected")


def on_message(msg):
    print(f"***** Received message: {msg}")


def on_disconnect():
    print(f"***** Disconnected")

    
async def main():
    eio = EngineIoClient(logger=False)

    eio.on("connect", on_connect)
    eio.on("message", on_message)
    eio.on("disconnect", on_disconnect)

    async with trio.open_nursery() as nursery:
        try:
            await eio.connect(nursery, "http://127.0.0.1:1234")
        except EngineIoConnectionError:
            return False
    return True


trio.run(main)
```

