MqttTransportFactory

Creates the MqttTransport for a given MqttEndpoint.

This is the seam that lets :core stay free of any concrete transport dependency: each transport module (mqtt-client-transport-tcp, mqtt-client-transport-ws) ships a factory, and the consumer supplies one via MqttConfig.Builder.transportFactory. Factories that handle different endpoint types can be combined with plus:

val client = MqttClient("sensor") {
transportFactory = TcpTransportFactory() + WebSocketTransportFactory()
}

Functions

Link copied to clipboard
abstract fun create(endpoint: MqttEndpoint): MqttTransport

Create a fresh, unconnected MqttTransport for endpoint.

Link copied to clipboard

Combine two factories into one that delegates to whichever supports the endpoint, trying the left-hand factory first. Use this to accept more than one endpoint type (e.g. both TCP and WebSocket) from a single client.

Link copied to clipboard
abstract fun supports(endpoint: MqttEndpoint): Boolean

Whether this factory can create a transport for endpoint.