Files
NebulaShell/store/@{FutureOSS}/ws-api
qwen.ai[bot] 27a1eb8a3c ### User query:
这次提交的标题

### Changes made to the code/files:

Title: Remove PHP dependencies and refactor UI rendering to pure HTML templates

Key features implemented:
- Refactored dashboard plugin to remove PHP dependency and implement pure HTML/CSS/JS template rendering
- Updated log-terminal plugin to replace PHP-based UI with native Python HTML template generation
- Modified package manager plugin to eliminate PHP view files and use direct HTML string construction
- Removed all PHP view template files across dashboard, log-terminal, and package manager plugins
- Updated .gitignore to include additional build artifacts and environment files
- Enhanced dashboard with real-time metrics, system information, and network statistics without external PHP processing

The overall change migrates the system from requiring PHP for UI rendering to using pure Python-based HTML template generation, simplifying deployment and removing external dependencies.
2026-04-25 09:55:28 +00:00
..
2026-04-25 09:55:28 +00:00
2026-04-17 23:15:15 +08:00
2026-04-17 23:15:15 +08:00

ws-api WebSocket API

提供 WebSocket 实时双向通信服务。

功能

  • WebSocket 服务器
  • 路由匹配
  • 中间件链(认证/日志)
  • 广播消息
  • 连接/断开/消息事件
  • 与 HTTP 插件集成

使用

ws = plugin_mgr.get("ws-api")

# 注册消息路由
ws.router.on_message("/chat", lambda client, msg: client.send({"echo": msg}))

# 广播
ws.server.broadcast({"type": "announcement", "data": "服务器维护通知"})

# 获取客户端列表
clients = ws.server.get_clients()

事件

# 通过 plugin-bridge 订阅 WS 事件
bridge = plugin_mgr.get("plugin-bridge")
bridge.event_bus.on("ws.connect", lambda event: print(f"新连接: {event.client.path}"))
bridge.event_bus.on("ws.message", lambda event: print(f"消息: {event.message}"))
bridge.event_bus.on("ws.disconnect", lambda event: print(f"断开: {event.client.id}"))

配置

{
  "config": {
    "args": {
      "host": "0.0.0.0",
      "port": 8081
    }
  }
}