You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this bug was found during an attempt at writing an example http-server in kotlin using TbdexHttpServer.
funmain() {
val serverConfig =TbdexHttpServerConfig(
port =8080,
pfiDid =DidDht.create(InMemoryKeyManager()).uri,
offeringsApi =FakeOfferingsApi(),
exchangesApi =FakeExchangesApi()
)
val tbdexServer =TbdexHttpServer(serverConfig)
tbdexServer.submit(SubmitKind.rfq) { call, messageKind, offering ->println("Saving RFQ...")
println("Validating RFQ.claims against Offering...")
println("Generating a Quote...")
println("Saving a Quote...")
// this line does not compile// error message: Suspend function 'respond' should be called only from a coroutine or another suspend function
call.respond(HttpStatusCode.Accepted)
}
tbdexServer.start()
}
in order to return a response, the callback must call ApplicationCall.respond() which is a coroutine function. therefore, the callback must also be a coroutine.
changing typealias SubmitCallback = (ApplicationCall, MessageKind, Offering?) -> Unit to typealias SubmitCallback = suspend (ApplicationCall, MessageKind, Offering?) -> Unit seems to do the trick, but needs testing to confirm.
The text was updated successfully, but these errors were encountered:
jiyoonie9
changed the title
[bug] SubmitCallback and GetCallBack functions must be coroutines
[bug] SubmitCallback and GetCallBack functions must be coroutines. Also, callbacks must pass in the Message, not MessageKind
Jan 31, 2024
jiyoonie9
changed the title
[bug] SubmitCallback and GetCallBack functions must be coroutines. Also, callbacks must pass in the Message, not MessageKind
[bug] SubmitCallback and GetCallBack functions must be coroutines.
Jan 31, 2024
this bug was found during an attempt at writing an example http-server in kotlin using TbdexHttpServer.
in order to return a response, the callback must call
ApplicationCall.respond()
which is a coroutine function. therefore, the callback must also be a coroutine.changing
typealias SubmitCallback = (ApplicationCall, MessageKind, Offering?) -> Unit
totypealias SubmitCallback = suspend (ApplicationCall, MessageKind, Offering?) -> Unit
seems to do the trick, but needs testing to confirm.The text was updated successfully, but these errors were encountered: