Skip to content

Elmeric/trio-engineio

Repository files navigation

Trio-Engine.IO

python Code style: black Tests Coverage Status license

An asynchronous Engine.IO client using the trio framework.

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

Requirements

Usage

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)