Add bot.job as parent of NetworkHandlerSupport

This commit is contained in:
Him188 2021-06-08 12:39:36 +08:00
parent 5f7f350eb5
commit c8def70594

View File

@ -32,9 +32,11 @@ import kotlin.reflect.KClass
* Implements basic logics of [NetworkHandler] * Implements basic logics of [NetworkHandler]
*/ */
internal abstract class NetworkHandlerSupport( internal abstract class NetworkHandlerSupport(
override val context: NetworkHandlerContext, final override val context: NetworkHandlerContext,
coroutineContext: CoroutineContext = EmptyCoroutineContext, additionalCoroutineContext: CoroutineContext = EmptyCoroutineContext,
) : NetworkHandler, CoroutineScope by coroutineContext.childScope(SupervisorJob()) { ) : NetworkHandler, CoroutineScope {
final override val coroutineContext: CoroutineContext =
additionalCoroutineContext.childScopeContext(SupervisorJob(context.bot.coroutineContext.job))
protected abstract fun initialState(): BaseStateImpl protected abstract fun initialState(): BaseStateImpl
protected abstract suspend fun sendPacketImpl(packet: OutgoingPacket) protected abstract suspend fun sendPacketImpl(packet: OutgoingPacket)