This commit is contained in:
parent
3acd5ba0e3
commit
cceb6e69e2
@ -4,7 +4,9 @@ import com.google.gson.GsonBuilder
|
|||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
import io.ktor.application.*
|
import io.ktor.application.*
|
||||||
import io.ktor.config.*
|
import io.ktor.config.*
|
||||||
|
import io.ktor.http.content.*
|
||||||
import io.ktor.request.*
|
import io.ktor.request.*
|
||||||
|
import io.ktor.response.*
|
||||||
import io.ktor.routing.*
|
import io.ktor.routing.*
|
||||||
import io.ktor.util.*
|
import io.ktor.util.*
|
||||||
import kotlin.text.toCharArray
|
import kotlin.text.toCharArray
|
||||||
@ -41,10 +43,22 @@ fun Application.module(testing: Boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
routing {
|
routing {
|
||||||
get("/benchmark") {
|
get("/sample"){
|
||||||
val requestBody : String = call.receiveText()
|
call.respond("0")
|
||||||
val msgObj: MessageObject = gson.fromJson(requestBody,MessageObject::class.java)
|
}
|
||||||
|
post("/benchmark") {
|
||||||
|
val multipart = call.receiveMultipart()
|
||||||
|
multipart.forEachPart { part ->
|
||||||
|
when (part) {
|
||||||
|
is PartData.FormItem -> {
|
||||||
|
if (part.name == "description") {
|
||||||
|
val msgObj: MessageObject = gson.fromJson(part.value,MessageObject::class.java)
|
||||||
mqttClient.publish("command/${msgObj.device_id}", message)
|
mqttClient.publish("command/${msgObj.device_id}", message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
part.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user