Jess Brent
09/07/2020, 12:59 AM{
"op": "op type",
"data": {
"id": "",
"name": ""
}
}
for some context, the server utilizes both http and websockets.
the op is something like GetSite
or GetUser
and the data block is an array of the op's values.
right now i'm running into an issue where it can't figure out what to use for the data block when receiving a response on the websocket.
i'm starting to feel like it won't be possible to utilize one set of classes for both http/ws.
i got the following to work but something about it just feels hacky 😓
@Serializable
class SampleRequest {
private val op = "GetThing"
var data: Data
constructor(auth: String?): super() {
data = Data(auth)
}
@Serializable
class Data(
val auth: String?
)
}
@Serializable
class SampleResponse {
private val op = "GetThing"
var data: Data
constructor(id: Int, name: String): super() {
data = Data(id, name)
}
@Serializable
class Data(
val id: Int,
val name: String
)
}
Jess Brent
09/07/2020, 1:24 AMJess Brent
09/07/2020, 7:58 PMtravis
09/08/2020, 5:43 AMJess Brent
09/08/2020, 5:09 PMJess Brent
09/08/2020, 5:11 PMJess Brent
09/08/2020, 5:15 PM