All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pubnub.api.subscribe.eventengine.effect.EmitMessagesEffect.kt Maven / Gradle / Ivy

Go to download

PubNub is a cross-platform client-to-client (1:1 and 1:many) push service in the cloud, capable of broadcasting real-time messages to millions of web and mobile clients simultaneously, in less than a quarter second!

There is a newer version: 10.2.0
Show newest version
package com.pubnub.api.subscribe.eventengine.effect

import com.pubnub.api.eventengine.Effect
import com.pubnub.api.models.consumer.pubsub.PNEvent
import com.pubnub.api.models.consumer.pubsub.PNMessageResult
import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult
import com.pubnub.api.models.consumer.pubsub.PNSignalResult
import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult
import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult
import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult
import org.slf4j.LoggerFactory

internal class EmitMessagesEffect(
    private val messagesConsumer: MessagesConsumer,
    private val messages: List
) : Effect {
    private val log = LoggerFactory.getLogger(EmitMessagesEffect::class.java)

    override fun runEffect() {
        log.trace("Running EmitMessagesEffect")
        for (message in messages) {
            when (message) {
                is PNMessageResult -> messagesConsumer.announce(message)
                is PNPresenceEventResult -> messagesConsumer.announce(message)
                is PNSignalResult -> messagesConsumer.announce(message)
                is PNMessageActionResult -> messagesConsumer.announce(message)
                is PNObjectEventResult -> messagesConsumer.announce(message)
                is PNFileEventResult -> messagesConsumer.announce(message)
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy