InMemorySessions

class InMemorySessions(transport: InMemoryTransport, identity: PeerIdentity = PeerIdentity.None) : DatagramTransport(source)

A stand-in for a DTLS layer on an InMemoryTransport, for tests of what a CoAP endpoint does with secure sessions: every peer appears as an Endpoint.Secure, one session per address, authenticated as identity, and nothing is encrypted. endAll ends every session at once, as a DTLS layer reports sessions that closed (DatagramEvent.SessionEnded, RFC 7252 §9.1.1); a send to an ended session throws SessionEndedException, and the next datagram to or from the address opens a new session. Safe to use from any coroutine.

Constructors

Link copied to clipboard
constructor(transport: InMemoryTransport, identity: PeerIdentity = PeerIdentity.None)

Properties

Link copied to clipboard

The address this side is attached at.

Link copied to clipboard
open override val maxDatagramSize: Int

Functions

Link copied to clipboard
open suspend override fun close()
Link copied to clipboard
suspend fun endAll(reason: SessionEndReason = SessionEndReason.CLOSED_BY_PEER)

Ends every session for reason; the receiver hears of each one as a DatagramEvent.SessionEnded.

Link copied to clipboard
open suspend override fun receive(): DatagramEvent
Link copied to clipboard
open suspend override fun send(to: Endpoint, datagram: ByteArray)
Link copied to clipboard
suspend fun sessionTo(address: Endpoint.Udp): Endpoint.Secure

The session to address, opened if there is none.

Link copied to clipboard
open override fun toString(): String