INNER CODE UNIT · Python

__on_connect

sabuhish/fastapi-mqtt · fastapi_mqtt/fastmqtt.py:155

    def __on_connect(self, client: MQTTClient, flags: int, rc: int, properties: Any) -> None:
        """
        Generic on connecting handler, it would call user handler if defined.
        Will perform subscription for given topics.
        It cannot be done earlier, since subscription relies on connection.
        """
        if self.mqtt_handlers.user_connect_handler is not None:
            self.mqtt_handlers.user_connect_handler(client, flags, rc, properties)

        for topic in self.subscriptions:
            self._logger.debug("Subscribing for %s", topic)
            self.client.subscribe(self.subscriptions[topic][0])

    async def __on_message(
        self, client: MQTTClient, topic: str, payload: bytes, qos: int, properties: Any
    ) -> Any:
        """
        Generic on message handler, it will call user handler if defined.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…