Skip to content

Commit

Permalink
ZenohId: renaming from ZenohID to ZenohId
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIMP committed Sep 19, 2024
1 parent 57abe17 commit 163d2cf
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 34 deletions.
2 changes: 1 addition & 1 deletion zenoh-jni/src/zenoh_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use zenoh::session::ZenohId;
/// Returns the string representation of a ZenohID.
#[no_mangle]
#[allow(non_snake_case)]
pub extern "C" fn Java_io_zenoh_jni_JNIZenohID_toStringViaJNI(
pub extern "C" fn Java_io_zenoh_jni_JNIZenohId_toStringViaJNI(
mut env: JNIEnv,
_class: JClass,
zenoh_id: JByteArray,
Expand Down
1 change: 0 additions & 1 deletion zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package io.zenoh

import io.zenoh.jni.JNIConfig
import io.zenoh.protocol.ZenohID
import java.io.File
import java.nio.file.Path
import kotlinx.serialization.json.JsonElement
Expand Down
8 changes: 4 additions & 4 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import io.zenoh.prelude.Encoding
import io.zenoh.prelude.QoS
import io.zenoh.protocol.IntoZBytes
import io.zenoh.protocol.ZBytes
import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId
import io.zenoh.publication.Delete
import io.zenoh.publication.Publisher
import io.zenoh.publication.Put
Expand Down Expand Up @@ -872,15 +872,15 @@ class Session private constructor(private val config: Config) : AutoCloseable {
jniSession?.run { performDelete(keyExpr, delete) }
}

internal fun zid(): Result<ZenohID> {
internal fun zid(): Result<ZenohId> {
return jniSession?.zid() ?: Result.failure(sessionClosedException)
}

internal fun getPeersId(): Result<List<ZenohID>> {
internal fun getPeersId(): Result<List<ZenohId>> {
return jniSession?.peersZid() ?: Result.failure(sessionClosedException)
}

internal fun getRoutersId(): Result<List<ZenohID>> {
internal fun getRoutersId(): Result<List<ZenohId>> {
return jniSession?.routersZid() ?: Result.failure(sessionClosedException)
}

Expand Down
14 changes: 7 additions & 7 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/SessionInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@

package io.zenoh

import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId

/**
* Class allowing to obtain the information of a [Session].
*/
class SessionInfo(private val session: Session) {

/**
* Return the [ZenohID] of the current Zenoh [Session]
* Return the [ZenohId] of the current Zenoh [Session]
*/
fun zid(): Result<ZenohID> {
fun zid(): Result<ZenohId> {
return session.zid()
}

/**
* Return the [ZenohID] of the zenoh peers the session is currently connected to.
* Return the [ZenohId] of the zenoh peers the session is currently connected to.
*/
fun peersZid(): Result<List<ZenohID>> {
fun peersZid(): Result<List<ZenohId>> {
return session.getPeersId()
}

/**
* Return the [ZenohID] of the zenoh routers the session is currently connected to.
* Return the [ZenohId] of the zenoh routers the session is currently connected to.
*/
fun routersZid(): Result<List<ZenohID>> {
fun routersZid(): Result<List<ZenohId>> {
return session.getRoutersId()
}
}
4 changes: 2 additions & 2 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package io.zenoh.jni
import io.zenoh.Config
import io.zenoh.handlers.Callback
import io.zenoh.jni.callbacks.JNIScoutCallback
import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId
import io.zenoh.scouting.Hello
import io.zenoh.scouting.Scout
import io.zenoh.scouting.WhatAmI
Expand All @@ -37,7 +37,7 @@ internal class JNIScout(private val ptr: Long) {
receiver: R
): Result<Scout<R>> = runCatching {
val scoutCallback = JNIScoutCallback { whatAmI2: Int, id: ByteArray, locators: List<String> ->
callback.run(Hello(WhatAmI.fromInt(whatAmI2), ZenohID(id), locators))
callback.run(Hello(WhatAmI.fromInt(whatAmI2), ZenohId(id), locators))
}
val binaryWhatAmI: Int = whatAmI.map { it.value }.reduce { acc, it -> acc or it }
val ptr = scoutViaJNI(binaryWhatAmI, scoutCallback, config?.jniConfig?.ptr)
Expand Down
18 changes: 9 additions & 9 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNISession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import io.zenoh.jni.callbacks.JNISubscriberCallback
import io.zenoh.keyexpr.KeyExpr
import io.zenoh.prelude.*
import io.zenoh.protocol.IntoZBytes
import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId
import io.zenoh.protocol.into
import io.zenoh.publication.Delete
import io.zenoh.publication.Publisher
Expand Down Expand Up @@ -170,10 +170,10 @@ internal class JNISession {
QoS(CongestionControl.fromInt(congestionControl), Priority.fromInt(priority), express),
attachmentBytes?.into()
)
reply = Reply(replierId?.let { ZenohID(it) }, Result.success(sample))
reply = Reply(replierId?.let { ZenohId(it) }, Result.success(sample))
} else {
reply = Reply(
replierId?.let { ZenohID(it) }, Result.failure(
replierId?.let { ZenohId(it) }, Result.failure(
ReplyError(
payload.into(),
Encoding(encodingId, schema = encodingSchema)
Expand Down Expand Up @@ -251,16 +251,16 @@ internal class JNISession {
)
}

fun zid(): Result<ZenohID> = runCatching {
ZenohID(getZidViaJNI(sessionPtr.get()))
fun zid(): Result<ZenohId> = runCatching {
ZenohId(getZidViaJNI(sessionPtr.get()))
}

fun peersZid(): Result<List<ZenohID>> = runCatching {
getPeersZidViaJNI(sessionPtr.get()).map { ZenohID(it) }
fun peersZid(): Result<List<ZenohId>> = runCatching {
getPeersZidViaJNI(sessionPtr.get()).map { ZenohId(it) }
}

fun routersZid(): Result<List<ZenohID>> = runCatching {
getRoutersZidViaJNI(sessionPtr.get()).map { ZenohID(it) }
fun routersZid(): Result<List<ZenohId>> = runCatching {
getRoutersZidViaJNI(sessionPtr.get()).map { ZenohId(it) }
}

@Throws(Exception::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package io.zenoh.jni

import io.zenoh.ZenohLoad

internal object JNIZenohID {
internal object JNIZenohId {

init {
ZenohLoad
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@

package io.zenoh.protocol

import io.zenoh.jni.JNIZenohID
import io.zenoh.jni.JNIZenohId

/**
* The global unique id of a Zenoh peer.
*/
data class ZenohID internal constructor(internal val bytes: ByteArray) {
data class ZenohId internal constructor(internal val bytes: ByteArray) {

override fun toString(): String {
return JNIZenohID.toStringViaJNI(bytes)
return JNIZenohId.toStringViaJNI(bytes)
}

override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false

other as ZenohID
other as ZenohId

return bytes.contentEquals(other.bytes)
}
Expand Down
4 changes: 2 additions & 2 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/query/Reply.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package io.zenoh.query

import io.zenoh.ZenohType
import io.zenoh.sample.Sample
import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId
import io.zenoh.queryable.Query

/**
Expand Down Expand Up @@ -44,4 +44,4 @@ import io.zenoh.queryable.Query
* @property replierId: unique ID identifying the replier, may be null in case the network cannot provide it
* (@see https://github.com/eclipse-zenoh/zenoh/issues/709#issuecomment-2202763630).
*/
data class Reply(val replierId: ZenohID?, val result: Result<Sample>) : ZenohType
data class Reply(val replierId: ZenohId?, val result: Result<Sample>) : ZenohType
6 changes: 3 additions & 3 deletions zenoh-kotlin/src/commonMain/kotlin/io/zenoh/scouting/Hello.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package io.zenoh.scouting

import io.zenoh.ZenohType
import io.zenoh.protocol.ZenohID
import io.zenoh.protocol.ZenohId

/**
* Hello message received while scouting.
*
* @property whatAmI [WhatAmI] configuration: it indicates the role of the zenoh node sending the HELLO message.
* @property zid [ZenohID] of the node sending the hello message.
* @property zid [ZenohId] of the node sending the hello message.
* @property locators The locators of this hello message.
* @see Scout
*/
data class Hello(val whatAmI: WhatAmI, val zid: ZenohID, val locators: List<String>): ZenohType
data class Hello(val whatAmI: WhatAmI, val zid: ZenohId, val locators: List<String>): ZenohType

0 comments on commit 163d2cf

Please sign in to comment.