您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AsyncResponseHandler.kt 692B

123456789101112131415161718192021
  1. package com.dmdirc.ktirc.events.handlers
  2. import com.dmdirc.ktirc.IrcClient
  3. import com.dmdirc.ktirc.events.IrcEvent
  4. import kotlinx.coroutines.CoroutineScope
  5. import kotlinx.coroutines.GlobalScope
  6. import kotlinx.coroutines.launch
  7. internal class AsyncResponseHandler(private val scope: CoroutineScope = GlobalScope) : EventHandler {
  8. override fun processEvent(client: IrcClient, event: IrcEvent) {
  9. client.serverState.asyncResponseState.pendingResponses.values
  10. .filter { it.second(event) }
  11. .forEach {
  12. scope.launch {
  13. it.first.send(event)
  14. }
  15. }
  16. }
  17. }