Skip to content

Latest commit

 

History

History
57 lines (36 loc) · 1.73 KB

README.md

File metadata and controls

57 lines (36 loc) · 1.73 KB

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)