mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
fixes
This commit is contained in:
parent
9307582654
commit
006251ed07
@ -77,7 +77,6 @@ fun startListenWebhooks(
|
|||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
): ApplicationEngine {
|
): ApplicationEngine {
|
||||||
lateinit var engine: ApplicationEngine
|
|
||||||
val env = applicationEngineEnvironment {
|
val env = applicationEngineEnvironment {
|
||||||
|
|
||||||
module {
|
module {
|
||||||
@ -103,10 +102,10 @@ fun startListenWebhooks(
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
engine = embeddedServer(engineFactory, env)
|
|
||||||
engine.start(false)
|
|
||||||
|
|
||||||
return engine
|
return embeddedServer(engineFactory, env).also {
|
||||||
|
it.start(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun RequestsExecutor.internalSetWebhookInfoAndStartListenWebhooks(
|
private suspend fun RequestsExecutor.internalSetWebhookInfoAndStartListenWebhooks(
|
||||||
@ -119,14 +118,10 @@ private suspend fun RequestsExecutor.internalSetWebhookInfoAndStartListenWebhook
|
|||||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
): Job {
|
): ApplicationEngine {
|
||||||
return try {
|
return try {
|
||||||
execute(setWebhookRequest)
|
execute(setWebhookRequest)
|
||||||
val engine = startListenWebhooks(listenPort, engineFactory, exceptionsHandler, listenHost, listenRoute, privateKeyConfig, scope, block)
|
startListenWebhooks(listenPort, engineFactory, exceptionsHandler, listenHost, listenRoute, privateKeyConfig, scope, block)
|
||||||
scope.launch {
|
|
||||||
engine.environment.parentCoroutineContext[Job] ?.join()
|
|
||||||
engine.stop(1000, 5000)
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
throw e
|
throw e
|
||||||
}
|
}
|
||||||
@ -154,7 +149,7 @@ suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
|||||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
): Job = internalSetWebhookInfoAndStartListenWebhooks(
|
): ApplicationEngine = internalSetWebhookInfoAndStartListenWebhooks(
|
||||||
listenPort,
|
listenPort,
|
||||||
engineFactory,
|
engineFactory,
|
||||||
setWebhookRequest as Request<Boolean>,
|
setWebhookRequest as Request<Boolean>,
|
||||||
@ -188,7 +183,7 @@ suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
|||||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||||
block: UpdateReceiver<Update>
|
block: UpdateReceiver<Update>
|
||||||
): Job = internalSetWebhookInfoAndStartListenWebhooks(
|
): ApplicationEngine = internalSetWebhookInfoAndStartListenWebhooks(
|
||||||
listenPort,
|
listenPort,
|
||||||
engineFactory,
|
engineFactory,
|
||||||
setWebhookRequest as Request<Boolean>,
|
setWebhookRequest as Request<Boolean>,
|
||||||
|
Loading…
Reference in New Issue
Block a user