Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Shamrock: fix GlobalEventTransmitter x2
Browse files Browse the repository at this point in the history
  • Loading branch information
whitechi73 committed Feb 11, 2024
1 parent 65f5436 commit 27b4c26
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -557,20 +562,29 @@ internal object GlobalEventTransmitter: BaseSvc() {

@ShamrockDsl
suspend inline fun onMessageEvent(collector: FlowCollector<Pair<MsgRecord, MessageEvent>>) {
messageEventFlow
.collect(collector)
messageEventFlow.collect {
GlobalScope.launch {
collector.emit(it)
}
}
}

@ShamrockDsl
suspend inline fun onNoticeEvent(collector: FlowCollector<NoticeEvent>) {
noticeEventFlow
.collect(collector)
noticeEventFlow.collect {
GlobalScope.launch {
collector.emit(it)
}
}
}

@ShamrockDsl
suspend inline fun onRequestEvent(collector: FlowCollector<RequestEvent>) {
requestEventFlow
.collect(collector)
requestEventFlow.collect {
GlobalScope.launch {
collector.emit(it)
}
}
}
}

Expand Down

0 comments on commit 27b4c26

Please sign in to comment.