You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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. }