事件流与生命周期
SSE 实时事件流
通过 Server-Sent Events 监听设备心跳、前台切换与系统通知
- 连接端点:
GET http://localhost:58166/gateway/sse - 请求头:
Accept: text/event-stream,X-AppKey: <your-key>
核心事件载荷
{
"type": "HEARTBEAT",
"device_id": "848bd13e2f9",
"battery": 92,
"cpu": 15.2,
"mem": 48.6,
"storage": 55.1,
"app": "com.tencent.mm",
"status": "online"
}
{
"type": "GUARD_EVENT",
"event": "NOTIFICATION_POSTED",
"device_id": "848bd13e2f9",
"package_name": "com.tencent.mm",
"app_label": "微信",
"title": "客户A",
"content": "请问这款商品有现货吗?",
"post_time": 1717171717000
}
{
"type": "DEVICE_LIST_SYNC",
"devices": [
{ "device_id": "848bd13e2f9", "model": "Langhua AI Phone Pro", "status": "online" }
]
}
{
"type": "DEVICE_TASK",
"event": "SUBMIT",
"device_id": "848bd13e2f9",
"task_id": "task-abc-123",
"goal": "帮我发个朋友圈"
}