Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coroutine support for client.send #157

Open
VovkaSOL opened this issue Oct 25, 2023 · 1 comment
Open

Coroutine support for client.send #157

VovkaSOL opened this issue Oct 25, 2023 · 1 comment

Comments

@VovkaSOL
Copy link

Hi, now client.send return future, but if we use Kotlin in client app, we can use coroutine for non blocking. Please add coroutine callback wrapper with suspendCoroutine.

@VovkaSOL
Copy link
Author

    suspend fun suspendSendMsg(request: String): String {
        return suspendCoroutine { continuation ->
            try {
                sendMsg(request) { response ->
                    //continuation.resumeWith(Result.failure(InternalTimeoutException( "Таймаут ответа ${request!!::class.java.canonicalName} со временем ожидания ${finalTimeout.toMillis()} миллисекунд" ) ))
                    continuation.resumeWith(Result.success(response))
                }
            } catch (e: Exception) {
                LOGGER.error("что то сломалось при отправке iso сообщения", e)
                throw RuntimeException("что то сломалось при отправке iso сообщения")
            }
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant