InMemoryLink

sealed class InMemoryLink(source)

One of the two ways a CoAP endpoint reaches a peer, in memory, so that one test runs over both and checks that the exchanges behave the same: Datagrams on an InMemoryNetwork (RFC 7252), Connections on InMemoryConnections (RFC 8323).

server attaches what a server endpoint is built on, client what a client endpoint is, each a Side with the arguments of the endpoint's constructor; uri is the server's base URI and cut ends every way between the two at once.

val link = InMemoryLink.Connections(InMemoryConnections())
val side = link.server()
val endpoint = CoapEndpoint(backgroundScope, config, side.transport, side.connectors, side.listeners)

Inheritors

Types

Link copied to clipboard
class Connections(val connections: InMemoryConnections, val scheme: CoapScheme = CoapScheme.COAP_TCP, val port: Int = DEFAULT_PORT, clientIdentity: PeerIdentity = PeerIdentity.None) : InMemoryLink

Connections of scheme on connections to a listener at 127.0.0.1:port, whose TLS stand-in reports clientIdentity for every client (see InMemoryConnections.listen).

Link copied to clipboard
class Datagrams(val network: InMemoryNetwork, maxDatagramSize: Int = InMemoryNetwork.DEFAULT_MAX_DATAGRAM_SIZE, identity: PeerIdentity = PeerIdentity.None) : InMemoryLink

Datagrams on network, through InMemorySessions on both sides, so that cut has sessions to end: the endpoints see each other as Endpoint.Secure peers whose DTLS layer authenticated identity, by default nobody, and messages go in datagrams of at most maxDatagramSize bytes.

Link copied to clipboard
class Side

What one endpoint is built on: a datagram transport, connectors and listeners, as the CoAP endpoint's constructor takes them, and how it addresses the other side (peer).

Properties

Link copied to clipboard
abstract val scheme: CoapScheme

The URI scheme of the server.

Link copied to clipboard
abstract val uri: String

<scheme>://<host>:<port> of the server; known once server attached it.

Functions

Link copied to clipboard
abstract suspend fun client(): InMemoryLink.Side

Attaches a client side; as often as the test needs clients.

Link copied to clipboard
abstract suspend fun cut()

Ends every way between the sides at once: every session over Datagrams ends, as a DTLS layer reports (RFC 7252 §9.1.1), and every connection breaks (RFC 8323 §3.4). What comes later opens new ones.

Link copied to clipboard
abstract suspend fun server(): InMemoryLink.Side

Attaches the server side; once per link.