LanAdvertiser

actual class LanAdvertiser(serviceType: String)

Advertises a service on the local network so nearby peers can discover it.

serviceType namespaces the advertisement. On Android NSD and iOS/Bonjour it is the DNS-SD service type (e.g. "_kursi._tcp"); the JVM UDP beacon uses it as a magic wire token so foreign traffic and other services on the shared beacon port are ignored. Two apps that pick distinct service types can coexist on one subnet. Changing it is a breaking change to discovery compatibility.

Platform actuals:

  • android — android.net.nsd.NsdManager (DNS-SD). Needs an app android.content.Context installed once via installLanContext(...); without it, advertise/discover degrade to no-ops.

  • iosNSNetService / Bonjour.

  • jvm — a real UDP-broadcast beacon (java.net.DatagramSocket) on LAN_UDP_PORT.

  • wasm — safe no-op (browsers cannot open raw sockets); start/stop succeed and do nothing.

Lifecycle: construct with a serviceType, call start with the coordinates, and stop when done. Implementations are NOT required to be restartable after stop; create a new instance per ad.

expect class LanAdvertiser(serviceType: String)

Advertises a service on the local network so nearby peers can discover it.

serviceType namespaces the advertisement. On Android NSD and iOS/Bonjour it is the DNS-SD service type (e.g. "_kursi._tcp"); the JVM UDP beacon uses it as a magic wire token so foreign traffic and other services on the shared beacon port are ignored. Two apps that pick distinct service types can coexist on one subnet. Changing it is a breaking change to discovery compatibility.

Platform actuals:

  • android — android.net.nsd.NsdManager (DNS-SD). Needs an app android.content.Context installed once via installLanContext(...); without it, advertise/discover degrade to no-ops.

  • iosNSNetService / Bonjour.

  • jvm — a real UDP-broadcast beacon (java.net.DatagramSocket) on LAN_UDP_PORT.

  • wasm — safe no-op (browsers cannot open raw sockets); start/stop succeed and do nothing.

Lifecycle: construct with a serviceType, call start with the coordinates, and stop when done. Implementations are NOT required to be restartable after stop; create a new instance per ad.

actual class LanAdvertiser(serviceType: String)

Advertises a service on the local network so nearby peers can discover it.

serviceType namespaces the advertisement. On Android NSD and iOS/Bonjour it is the DNS-SD service type (e.g. "_kursi._tcp"); the JVM UDP beacon uses it as a magic wire token so foreign traffic and other services on the shared beacon port are ignored. Two apps that pick distinct service types can coexist on one subnet. Changing it is a breaking change to discovery compatibility.

Platform actuals:

  • android — android.net.nsd.NsdManager (DNS-SD). Needs an app android.content.Context installed once via installLanContext(...); without it, advertise/discover degrade to no-ops.

  • iosNSNetService / Bonjour.

  • jvm — a real UDP-broadcast beacon (java.net.DatagramSocket) on LAN_UDP_PORT.

  • wasm — safe no-op (browsers cannot open raw sockets); start/stop succeed and do nothing.

Lifecycle: construct with a serviceType, call start with the coordinates, and stop when done. Implementations are NOT required to be restartable after stop; create a new instance per ad.

actual class LanAdvertiser(serviceType: String)

Advertises a service on the local network so nearby peers can discover it.

serviceType namespaces the advertisement. On Android NSD and iOS/Bonjour it is the DNS-SD service type (e.g. "_kursi._tcp"); the JVM UDP beacon uses it as a magic wire token so foreign traffic and other services on the shared beacon port are ignored. Two apps that pick distinct service types can coexist on one subnet. Changing it is a breaking change to discovery compatibility.

Platform actuals:

  • android — android.net.nsd.NsdManager (DNS-SD). Needs an app android.content.Context installed once via installLanContext(...); without it, advertise/discover degrade to no-ops.

  • iosNSNetService / Bonjour.

  • jvm — a real UDP-broadcast beacon (java.net.DatagramSocket) on LAN_UDP_PORT.

  • wasm — safe no-op (browsers cannot open raw sockets); start/stop succeed and do nothing.

Lifecycle: construct with a serviceType, call start with the coordinates, and stop when done. Implementations are NOT required to be restartable after stop; create a new instance per ad.

actual class LanAdvertiser(serviceType: String)

Advertises a service on the local network so nearby peers can discover it.

serviceType namespaces the advertisement. On Android NSD and iOS/Bonjour it is the DNS-SD service type (e.g. "_kursi._tcp"); the JVM UDP beacon uses it as a magic wire token so foreign traffic and other services on the shared beacon port are ignored. Two apps that pick distinct service types can coexist on one subnet. Changing it is a breaking change to discovery compatibility.

Platform actuals:

  • android — android.net.nsd.NsdManager (DNS-SD). Needs an app android.content.Context installed once via installLanContext(...); without it, advertise/discover degrade to no-ops.

  • iosNSNetService / Bonjour.

  • jvm — a real UDP-broadcast beacon (java.net.DatagramSocket) on LAN_UDP_PORT.

  • wasm — safe no-op (browsers cannot open raw sockets); start/stop succeed and do nothing.

Lifecycle: construct with a serviceType, call start with the coordinates, and stop when done. Implementations are NOT required to be restartable after stop; create a new instance per ad.

Constructors

Link copied to clipboard
actual constructor(serviceType: String)
expect constructor(serviceType: String)
actual constructor(serviceType: String)
actual constructor(serviceType: String)
actual constructor(serviceType: String)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
actual fun start(serviceName: String, payload: String, port: Int)

Begins advertising host:port / payload under serviceName. Safe to call once; calling again before stop is implementation-defined (prefer one instance per advertisement).

expect fun start(serviceName: String, payload: String, port: Int)

Begins advertising host:port / payload under serviceName. Safe to call once; calling again before stop is implementation-defined (prefer one instance per advertisement).

actual fun start(serviceName: String, payload: String, port: Int)

Begins advertising host:port / payload under serviceName. Safe to call once; calling again before stop is implementation-defined (prefer one instance per advertisement).

actual fun start(serviceName: String, payload: String, port: Int)

Begins advertising host:port / payload under serviceName. Safe to call once; calling again before stop is implementation-defined (prefer one instance per advertisement).

actual fun start(serviceName: String, payload: String, port: Int)

Begins advertising host:port / payload under serviceName. Safe to call once; calling again before stop is implementation-defined (prefer one instance per advertisement).

Link copied to clipboard
actual fun stop()

Stops advertising and releases platform resources. Idempotent.

expect fun stop()

Stops advertising and releases platform resources. Idempotent.

actual fun stop()

Stops advertising and releases platform resources. Idempotent.

actual fun stop()

Stops advertising and releases platform resources. Idempotent.

actual fun stop()

Stops advertising and releases platform resources. Idempotent.