Sfoglia il codice sorgente

And scope name for session

ryoii 3 anni fa
parent
commit
d54af8d996

+ 2 - 2
mirai-api-http-spi/src/main/java/net/mamoe/mirai/api/http/context/session/session.kt

@@ -27,7 +27,7 @@ class StandardSession constructor(
     override val manager: SessionManager,
 ) : AbstractSession() {
     private val supervisorJob = SupervisorJob()
-    override val coroutineContext: CoroutineContext = supervisorJob
+    override val coroutineContext: CoroutineContext = supervisorJob + CoroutineName("session-$key")
     private val lifeCounter = atomic(0)
 
     private lateinit var _bot: Bot
@@ -127,7 +127,7 @@ class ListenableSessionWrapper(val session: Session) : Session by session {
         check(isAuthed) { "Session is not authed" }
 
         val handler = botEventHandler ?: getExtElement(Key.botEventHandler)
-        val element = bot.eventChannel.subscribeAlways<BotEvent> { event ->
+        val element = bot.eventChannel.subscribeAlways(BotEvent::class, coroutineContext) { event ->
             handler?.invoke(session, event)
         }