Skip to main content

anyio 的 WebSocket 协议实现

项目描述

袜子

该库基于Sans-IO 库 wsproto实现了 WebSocket 协议。I/O 由anyio 项目处理,这使得该库与 asyncio、trio 和 curio 兼容。

构建状态 可维护性 代码因子 文件状态 PyPI 版本

安装

这个库需要 Python 3.5+。您可以直接从 PyPI 安装它:

python3 -m pip install -U anysocks

如果您想要最先进的开发版本,请直接从 GitHub 安装:

python3 -m pip install -U git+https://github.com/clamor-py/anysocks@master#egg=anysocks

文档

本 README 仅提供简短概述,请参阅此处的完整文档。

例子

import anyio
from anysocks import open_connection


async def main():
    async with open_connection('wss://echo.websocket.org') as con:
        print('Connection established!')

        # First, let's send some text to the server.
        text = input('What to send? ')
        await con.send_message(text)

        # Now, we receive and verify the server's response.
        message = await con.get_message()
        assert message == text, "Received {}, expected {}".format(message, text)

    print('Connection closed with code {}', con.close_code.value)

anyio.run(main)

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

anysocks-0.2.2.tar.gz (19.0 kB 查看哈希

已上传 source

内置分布

anysocks-0.2.2-py3-none-any.whl (11.9 kB 查看哈希

已上传 py3