diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/GlobalEventTransmitter.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/GlobalEventTransmitter.kt index 8267c8f..7c8d620 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/GlobalEventTransmitter.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/service/api/GlobalEventTransmitter.kt @@ -1,10 +1,15 @@ +@file:OptIn(DelicateCoroutinesApi::class) + package moe.fuqiuluo.shamrock.remote.service.api import com.tencent.qqnt.kernel.nativeinterface.MsgElement import com.tencent.qqnt.kernel.nativeinterface.MsgRecord +import kotlinx.coroutines.DelicateCoroutinesApi +import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.channels.BufferOverflow import kotlinx.coroutines.flow.FlowCollector import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.launch import moe.fuqiuluo.qqinterface.servlet.BaseSvc import moe.fuqiuluo.qqinterface.servlet.CardSvc import moe.fuqiuluo.qqinterface.servlet.GroupSvc @@ -557,20 +562,29 @@ internal object GlobalEventTransmitter: BaseSvc() { @ShamrockDsl suspend inline fun onMessageEvent(collector: FlowCollector>) { - messageEventFlow - .collect(collector) + messageEventFlow.collect { + GlobalScope.launch { + collector.emit(it) + } + } } @ShamrockDsl suspend inline fun onNoticeEvent(collector: FlowCollector) { - noticeEventFlow - .collect(collector) + noticeEventFlow.collect { + GlobalScope.launch { + collector.emit(it) + } + } } @ShamrockDsl suspend inline fun onRequestEvent(collector: FlowCollector) { - requestEventFlow - .collect(collector) + requestEventFlow.collect { + GlobalScope.launch { + collector.emit(it) + } + } } }