Dariusz Kuc
06/25/2020, 1:14 AM<http://client.ws|client.ws>() {
send(GQL_CONNECTION_INIT)
val ackFlow = incoming.receiveAsFlow()
// verify ack messages
send(GQL_START)
val response = incoming.receiveAsFlow() // <- HOW TO RETURN THIS?
// error handling, closing session and unsubscribing omitted for clarity
}
I was hoping to wrap the above in some method that returns the response: Flow
is that even possible? Further caveat is that this flow of responses would also have to be filtered for keep alive messages….Joe
06/25/2020, 3:40 PMval channel = Channel<Message>()
<http://client.ws|client.ws>() {
send(GQL_CONNECTION_INIT)
val ack = incoming.receive()
// verify ack message
send(GQL_START)
for (frame in incoming) {
val msg = Message(frame)
if (msg != GQL_KA) {
channel.send(msg)
}
}
}
return channel.consumeAsFlow()
you can make things more complicated by allowing a single client/connection to handle multiple concurrent queries, too, but a single-query-per-connection could work something like the above, and be extended further in the future to handle the connection orthogonal to a query. something to think about when designing the interface at least.Dariusz Kuc
06/25/2020, 3:41 PM