mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
feat.增加getImage接口
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Maa-HTTP接口实现
|
||||
|
||||
本项目为通过JNA(Java-Native-Access)调用Maa核心实现的HTTP+WebSocket接口实现.
|
||||
基于JNA(Java-Native-Access)调用Maa核心的HTTP+WebSocket接口实现.
|
||||
|
||||
## 接口实现情况
|
||||
|
||||
|
||||
@@ -161,6 +161,13 @@ data class DestroyRequest(
|
||||
val id: String,
|
||||
)
|
||||
|
||||
|
||||
@Serializable
|
||||
data class GetImage(
|
||||
@SerialName("id")
|
||||
val id: String,
|
||||
)
|
||||
|
||||
@SerialName("connect")
|
||||
@Serializable
|
||||
data class WsRequest(
|
||||
|
||||
@@ -7,6 +7,7 @@ import io.ktor.server.application.*
|
||||
import io.ktor.server.request.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
import io.ktor.utils.io.*
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
|
||||
|
||||
@@ -63,6 +64,19 @@ fun Application.httpRouting() {
|
||||
val list = MaaService.listInstance()
|
||||
call.respond(ListInstanceResponse(list).wapperToHttpResponse())
|
||||
}
|
||||
get("/getImage") {
|
||||
val id = call.request.queryParameters["id"]
|
||||
id?.let {
|
||||
|
||||
MaaService.getImage(it)
|
||||
}
|
||||
call.response.headers
|
||||
//todo
|
||||
}
|
||||
post("/listInstance") {
|
||||
val list = MaaService.listInstance()
|
||||
call.respond(ListInstanceResponse(list).wapperToHttpResponse())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,4 +95,8 @@ object MaaService {
|
||||
this.wsConnection -= connection
|
||||
}
|
||||
|
||||
fun getImage(id: String) : ByteArray? {
|
||||
return instancePool[id]?.getImage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user