anyio的websocket协议实现

anysocks的Python项目详细描述


任何袜子

这个库基于Sans-IO library wsproto实现the WebSocket protocol。 i/o由anyio project处理,这使得这个库与asyncio、trio和curio兼容。

Build StatusMaintainabilityCodeFactorDocumentation StatusPyPI version

安装

这个库需要Python3.5+。您可以直接从pypi安装它:

python3 -m pip install -U anysocks

如果您希望使用尖端的开发版本,请直接从github安装:

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

文档

本自述文件仅提供一个简短的概述,请参阅完整的文档here

示例

importanyiofromanysocksimportopen_connectionasyncdefmain():asyncwithopen_connection('wss://echo.websocket.org')ascon:print('Connection established!')# First, let's send some text to the server.text=input('What to send? ')awaitcon.send(text)# Now, we receive and verify the server's response.message=awaitcon.get_message()assertmessage==text,"Received {}, expected {}".format(message,text)print('Connection closed with code {}',con.close_code.value)anyio.run(main)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java Android Studio从XML中洗牌2D数组列   安卓 rx java obsever pojo模型的变化   java如何在安卓应用程序中以编程方式打开google教室   java如何将充满令牌的对象[]转换为整数数组?   java Minify Maven插件抛出“不支持JavaScript引擎”错误   java如何检查调用应用程序的用户是否具有绑定特权端口的权限?   java无法向firestore发送数据   jpanel Java向ScrollPane中嵌入的面板添加JLabel   将Bash脚本移植到Java   JavaSpring显示错误消息   java如何为这些路径表达式编写正则表达式   java如何通过编程在Android手机上获得时间?   Java:捕获未检查的异常与已检查的异常