From 27b4c26da7ad8b48d276ee9729f447ba51a288f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E6=B1=A0?= Date: Sun, 11 Feb 2024 14:28:07 +0800 Subject: [PATCH] `Shamrock`: fix GlobalEventTransmitter x2 --- .../service/api/GlobalEventTransmitter.kt | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) 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 8267c8f1..7c8d6202 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) + } + } } }