class

LavinMQ::MQTT::Broker

Inherits Reference < Object

Constants

Log = LavinMQ::Log.for("mqtt.broker")

Constructors

new(vhost : VHost)

The Broker class acts as an intermediary between the Server and MQTT connections. It is initialized by the Server and manages client connections, sessions, and message exchange. Responsibilities include:

  • Handling client connections and disconnections
  • Managing client sessions (clean and persistent)
  • Publishing messages to the exchange
  • Subscribing and unsubscribing clients to/from topics
  • Handling the retain store
  • Interfacing with the virtual host (vhost) and the exchange to route messages The Broker class helps keep the MQTT client concise and focused on the protocol.
Source

Instance methods

add_client(io, connection_info, user, packet) : Client
Source
close
Source
connection_limit_reached?(client_id : String) : Bool

A reconnecting client_id displaces the existing connection in add_client, so the connection count doesn't grow

Source
grant(session : Session, tf) : Protocol::SubAck::ReturnCode
Source
permission_service
Source
publish(packet : Protocol::Publish, ctx : PublishContext) : Bool

Returns false, without storing or routing the packet, during a disk alarm

Source
remove_client(client)
Source
run_client(io, connection_info, user, packet) : Client
Source
session_present?(client_id : String, clean_session) : Bool
Source
sessions
Source
subscribe(client, topics) : Array(Protocol::SubAck::ReturnCode)
Source
unsubscribe(client_id, topics)
Source
vhost
Source