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

Commit

Permalink
Shamrock: 实现事件推送
Browse files Browse the repository at this point in the history
Signed-off-by: 白池 <whitechi73@outlook.com>
  • Loading branch information
whitechi73 committed Mar 14, 2024
1 parent a95d8d8 commit 3a07116
Show file tree
Hide file tree
Showing 10 changed files with 1,217 additions and 236 deletions.
27 changes: 20 additions & 7 deletions xposed/src/main/java/kritor/service/EventService.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
package kritor.service

import io.grpc.Status
import io.grpc.StatusRuntimeException
import io.kritor.event.EventRequest
import io.kritor.event.EventServiceGrpcKt
import io.kritor.event.EventStructure
import io.kritor.event.EventType
import io.kritor.event.RequestPushEvent
import io.kritor.event.eventStructure
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import moe.fuqiuluo.shamrock.internals.GlobalEventTransmitter

object EventService: EventServiceGrpcKt.EventServiceCoroutineImplBase() {
override fun registerActiveListener(request: EventRequest): Flow<EventStructure> {
override fun registerActiveListener(request: RequestPushEvent): Flow<EventStructure> {
return channelFlow {
when(request.type!!) {
EventType.CORE_EVENT -> TODO()
EventType.MESSAGE -> GlobalEventTransmitter.onMessageEvent {
EventType.EVENT_TYPE_CORE_EVENT -> {}
EventType.EVENT_TYPE_MESSAGE -> GlobalEventTransmitter.onMessageEvent {
send(eventStructure {
this.type = EventType.MESSAGE
this.type = EventType.EVENT_TYPE_MESSAGE
this.message = it.second
})
}
EventType.NOTICE -> TODO()
EventType.REQUEST -> TODO()
EventType.UNRECOGNIZED -> TODO()
EventType.EVENT_TYPE_NOTICE -> GlobalEventTransmitter.onRequestEvent {
send(eventStructure {
this.type = EventType.EVENT_TYPE_NOTICE
this.request = it
})
}
EventType.EVENT_TYPE_REQUEST -> GlobalEventTransmitter.onNoticeEvent {
send(eventStructure {
this.type = EventType.EVENT_TYPE_NOTICE
this.notice = it
})
}
EventType.UNRECOGNIZED -> throw StatusRuntimeException(Status.INVALID_ARGUMENT)
}
}
}
Expand Down
Loading

0 comments on commit 3a07116

Please sign in to comment.