MessageConnection

A message stream: WebSocket (RFC 8323 coap+ws, coaps+ws), one CoAP message per binary frame. TLS for coaps+ws is always the WebSocket client's own (wss://), also in browsers.

Properties

Link copied to clipboard
abstract override val peerIdentity: PeerIdentity

The peer as authenticated by TLS, or PeerIdentity.None on plain WebSocket.

Link copied to clipboard
abstract override val remote: Endpoint

The peer. For a connection a Connector opened, the Endpoint it was asked to connect to.

Functions

Link copied to clipboard
abstract suspend override fun close()

Closes the connection; afterwards reading reports its end. Idempotent.

Link copied to clipboard
abstract suspend fun receive(): ByteArray?

The next message (a whole binary frame, reassembled if fragmented), or null once the connection has closed.

Link copied to clipboard
abstract suspend fun send(message: ByteArray)

Sends message as one binary frame; the bytes belong to the connection afterwards.