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

com.github.stormbit.sdk.longpoll.Queue.kt Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.github.stormbit.sdk.longpoll

import com.google.gson.JsonArray
import com.google.gson.JsonObject
import java.util.concurrent.CopyOnWriteArrayList

/**
 * Created by Storm-bit
 *
 * Queue of updates
 */
class Queue {
    /**
     * List of updates that we need to handle
     */
    @Volatile
    var updatesUser = CopyOnWriteArrayList()

    @Volatile
    var updatesGroup = CopyOnWriteArrayList()

    /**
     * We add all of updates from longpoll server
     * to queue
     *
     * @param elements Array of updates
     */
    fun putAll(elements: JsonArray) {
        elements.forEach {
            if (it is JsonArray) {
                updatesUser.add(it)
            } else if (it is JsonObject) {
                updatesGroup.add(it)
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy