publish

fun publish(name: String, type: String, retained: Boolean = false, properties: Map<String, Any> = emptyMap()): Int(source)

Publishes a topic and returns its id, or returns the id of the topic with this name if it is already published.

Clients subscribed to a matching name are told about the topic right away.

Parameters

name

The topic name, conventionally starting with /. Names starting with $ are reserved for the server.

type

The topic's type string, such as "json" or "msgpack". Prefer the overload that takes an NT4Type for the types that have one. A type string that isn't one of NT4Type's, other than json, is published as binary, which is how struct topics work.

retained

Whether the topic should stay announced when nothing is publishing to it.

properties

Other topic properties, such as unit, announced to clients. Values are strings, booleans or finite numbers. They are ignored if the topic is already published.

Throws

if the name is empty or reserved, the name has ever been published with a different type, or a property value is of another kind. A name keeps its type for as long as this server object exists, even after unpublish, because dashboards keep a field's first type and refuse values of another.


fun publish(name: String, type: NT4Type, retained: Boolean = false, properties: Map<String, Any> = emptyMap()): Int(source)

Publishes a topic of type. See the overload that takes a type string.