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

orbit.client.net.LocalNode.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0a19
Show newest version
/*
 Copyright (C) 2015 - 2019 Electronic Arts Inc.  All rights reserved.
 This file is part of the Orbit Project .
 See license in LICENSE.
 */

package orbit.client.net

import orbit.client.OrbitClientConfig
import orbit.shared.mesh.NodeCapabilities
import orbit.shared.mesh.NodeInfo
import orbit.util.concurrent.atomicSet
import java.util.concurrent.atomic.AtomicReference

internal class LocalNode(config: OrbitClientConfig) {
    private val ref = AtomicReference(
        NodeData(config.grpcEndpoint, config.namespace)
    )

    val status get() = ref.get()!!

    fun manipulate(body: (NodeData) -> NodeData) = ref.atomicSet(body)!!
}

internal data class NodeData(
    val grpcEndpoint: String,
    val namespace: String,
    val nodeInfo: NodeInfo? = null,
    val capabilities: NodeCapabilities? = null,
    val clientState: ClientState = ClientState.IDLE
)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy