fixes in build

This commit is contained in:
2020-08-11 22:18:57 +06:00
parent 3d3d184636
commit c3cf3f161a
3 changed files with 6 additions and 15 deletions

View File

@@ -11,8 +11,7 @@ import kotlinx.coroutines.flow.*
* @param checkReconnection This lambda will be called when it is required to reconnect to websocket to establish
* connection. Must return true in case if must be reconnected. By default always reconnecting
*/
inline fun <reified T> createStandardWebsocketFlow(
client: HttpClient,
inline fun <reified T> HttpClient.createStandardWebsocketFlow(
url: String,
crossinline checkReconnection: (Throwable?) -> Boolean = { true },
crossinline conversation: suspend (ByteArray) -> T
@@ -20,7 +19,7 @@ inline fun <reified T> createStandardWebsocketFlow(
val correctedUrl = url.asCorrectWebSocketUrl
return channelFlow {
val producerScope = this
val producerScope = this@channelFlow
do {
val reconnect = try {
safely(
@@ -28,7 +27,7 @@ inline fun <reified T> createStandardWebsocketFlow(
throw it
}
) {
client.ws(
ws(
correctedUrl
) {
while (true) {
@@ -62,8 +61,3 @@ inline fun <reified T> createStandardWebsocketFlow(
}
}
}
inline fun <reified T> HttpClient.createStandardWebsocketFlow(
url: String,
crossinline conversation: suspend (ByteArray) -> T
) = createStandardWebsocketFlow(this, url, conversation)