feat: Python/Java SDK 接入清单与打包文档
对真实 nixmsg 跑 DEVELOPMENT 第 9 节接入清单(跳过仅 JS 跨域),补 README/示例,并修 Paho/HiveMQ 真机联调死锁与鉴权分类。
This commit is contained in:
+40
-4
@@ -1,24 +1,60 @@
|
||||
# NixMsg Python SDK
|
||||
|
||||
包名 `nixmsg`,最低 Python 3.10。同步接口为主,`AsyncClient` 提供 asyncio 包装。
|
||||
包名 `nixmsg`,最低 Python 3.10。同步接口为主,同包提供 `AsyncClient` asyncio 包装。
|
||||
|
||||
## 安装
|
||||
|
||||
发布后(阶段 3):
|
||||
|
||||
```bash
|
||||
pip install nixmsg --index-url https://git.asio.asia/api/packages/nixevol/pypi/simple/
|
||||
```
|
||||
|
||||
本地开发:
|
||||
|
||||
```bash
|
||||
cd sdk/python
|
||||
python -m venv .venv
|
||||
# Windows: .venv\Scripts\activate
|
||||
pip install -e ".[dev]"
|
||||
```
|
||||
|
||||
## 最小示例
|
||||
|
||||
```python
|
||||
from nixmsg import Client, Target, Body
|
||||
from nixmsg import Body, Client, SendOptions, Target
|
||||
|
||||
c = Client()
|
||||
c.on_session(lambda token: print("session", token))
|
||||
c.on_message(lambda msg: print("msg", msg.id, msg.body.data))
|
||||
c.connect("ws://127.0.0.1:7443/mqtt", "device-1", password="secret")
|
||||
c.send(Target(kind="endpoint", id="device-2"), Body(data="hello"))
|
||||
c.send(
|
||||
Target(kind="endpoint", id="device-2"),
|
||||
Body(data="hello"),
|
||||
SendOptions(delay_ms=0),
|
||||
)
|
||||
c.close()
|
||||
```
|
||||
|
||||
许可证见 `LICENSE`(专有)。
|
||||
更完整的命令行示例见 `examples/minimal.py`。
|
||||
|
||||
## 打包(不发布)
|
||||
|
||||
```bash
|
||||
pip install build
|
||||
python -m build
|
||||
# 产物在 dist/,勿上传 PyPI;正式发布由总控在阶段 3 执行
|
||||
```
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
# 单元测试(假传输)+ 接入清单(会编译并启动真实 nixmsg)
|
||||
pytest
|
||||
```
|
||||
|
||||
接入清单覆盖 DEVELOPMENT 第 9 节(跳过仅 JS 的跨域项)。可用环境变量 `NIXMSG_BIN` 指定已编译二进制。
|
||||
|
||||
## 许可证
|
||||
|
||||
见 `LICENSE`(专有 / Proprietary)。
|
||||
|
||||
Reference in New Issue
Block a user