Skip to content

用于连接英雄联盟客户端(LeagueClientUpdate API)的中间组件

License

Notifications You must be signed in to change notification settings

LeagueTavern/LeagueMiddlewareService

Repository files navigation

LeagueMiddleware

用于连接英雄联盟客户端(LeagueClientUpdate API)的中间组件

node-current (tag) GitHub Issues

💻 平台支持

  • Windows
  • Macos(计划支持)

🍹 接口

本中间件在启动后,会开放HTTP WEBSOCKET两个服务。

  • HTTP部分的默认端口59101,负责发送请求给客户端,比如获取精粹数量 分解皮肤碎片
  • WEBSOCKET部分负责转发所有与客户端的数据给使用者,比如房间创建事件玩家状态变动事件

HTTP接口

1. 获取所有已连接客户端的数据
GET /api/get-clients
// Response
[
    {
        "accountId": "accountId", // 账户ID
        "puuid": "15911e14-89af-d8ad-2a29-ab8c1998ced2", // 账户PUUID
        "displayName": "displayName", // 账户名称
        "port": 53021, // 端口
        "token": "Ka9gf_aiNF0dFK1KAg-", // token
        "protocol": "https" // 协议 http/https
    },
    {
        "accountId": "accountId",
        "puuid": "15911e14-89af-d8ad-2a29-ab8c1998ced2",
        "displayName": "displayName",
        "port": 53021,
        "token": "Ka9gf_aiNF0dFK1KAg-",
        "protocol": "https"
    },
    ...
]
2. 发送请求给指定客户端
GET /client/:puuid/:url(*)
POST /client/:puuid/:url(*)
PUT /client/:puuid/:url(*)
PATCH /client/:puuid/:url(*)
DELETE /client/:puuid/:url(*)
OPTIONS /client/:puuid/:url(*)
HEAD /client/:puuid/:url(*)
// Response
// 返回对应LCU请求的结果
// ...

⚠️ 本请求需自行携带相应的 query-param params body

🌰 例子 & 解释
GET /client/15911e14-89af-d8ad-2a29-ab8c1998ced2/lol-summoner/v1/current-summoner
    /client/(puuid)                             /(url)

WEBSOCKET通信

该服务只会转发来自LCU通信隧道传输的数据和客户端的加入/退出信息,不会回应用户发送的任何信息。以下是你会接收到的 3 种数据:

// 客户端加入事件
{
  "type": "CLIENT_JOINED",
  "identification": {
    "accountId": "accountId", // 账户ID
    "puuid": "15911e14-89af-d8ad-2a29-ab8c1998ced2", // 账户PUUID
    "displayName": "displayName" // 账户名称
  }
}
// 客户端关闭事件
{
  "type": "CLIENT_LEFT",
  "identification": {
    "accountId": "accountId", // 账户ID
    "puuid": "15911e14-89af-d8ad-2a29-ab8c1998ced2", // 账户PUUID
    "displayName": "displayName" // 账户名称
  }
}
// 客户端隧道消息事件
{
  "type": "CLIENT_MESSAGE",
  "identification": {
    "accountId": "accountId", // 账户ID
    "puuid": "15911e14-89af-d8ad-2a29-ab8c1998ced2", // 账户PUUID
    "displayName": "displayName" // 账户名称
  },
  "message": {
    "eventType": "", // Method
    "uri": "/lol-xxxx/v1/xxxxx/xxxxx", //
    "data": {
      // 数据
      // 请参考RIOT开发者文档
    }
  }
}

🍗 项目启动

安装

npm install

调试

npm run dev

编译

npm run build

打包

Windows平台
npm run build:exe