kopia lustrzana https://github.com/Yakifo/amqtt
client connect/disconnect event callbacks now receive the client 'Session'
rodzic
1276503748
commit
f80939ffb8
|
@ -491,7 +491,9 @@ class Broker:
|
|||
self._sessions[client_session.client_id] = (client_session, handler)
|
||||
|
||||
await handler.mqtt_connack_authorize(authenticated)
|
||||
await self.plugins_manager.fire_event(BrokerEvents.CLIENT_CONNECTED, client_id=client_session.client_id)
|
||||
await self.plugins_manager.fire_event(BrokerEvents.CLIENT_CONNECTED,
|
||||
client_id=client_session.client_id,
|
||||
client_session=client_session)
|
||||
|
||||
self.logger.debug(f"{client_session.client_id} Start messages handling")
|
||||
await handler.start()
|
||||
|
@ -594,7 +596,9 @@ class Broker:
|
|||
self.logger.debug(f"{client_session.client_id} Disconnecting session")
|
||||
await self._stop_handler(handler)
|
||||
client_session.transitions.disconnect()
|
||||
await self.plugins_manager.fire_event(BrokerEvents.CLIENT_DISCONNECTED, client_id=client_session.client_id)
|
||||
await self.plugins_manager.fire_event(BrokerEvents.CLIENT_DISCONNECTED,
|
||||
client_id=client_session.client_id,
|
||||
client_session=client_session)
|
||||
|
||||
|
||||
async def _handle_subscription(
|
||||
|
|
|
@ -225,7 +225,7 @@ class BrokerSysPlugin(BasePlugin[BrokerContext]):
|
|||
if packet.fixed_header.packet_type == PUBLISH:
|
||||
self._stats[STAT_PUBLISH_SENT] += 1
|
||||
|
||||
async def on_broker_client_connected(self, client_id: str) -> None:
|
||||
async def on_broker_client_connected(self, client_id: str, client_session: Session) -> None:
|
||||
"""Handle broker client connection."""
|
||||
self._stats[STAT_CLIENTS_CONNECTED] += 1
|
||||
self._stats[STAT_CLIENTS_MAXIMUM] = max(
|
||||
|
@ -233,7 +233,7 @@ class BrokerSysPlugin(BasePlugin[BrokerContext]):
|
|||
self._stats[STAT_CLIENTS_CONNECTED],
|
||||
)
|
||||
|
||||
async def on_broker_client_disconnected(self, client_id: str) -> None:
|
||||
async def on_broker_client_disconnected(self, client_id: str, client_session: Session) -> None:
|
||||
"""Handle broker client disconnection."""
|
||||
self._stats[STAT_CLIENTS_CONNECTED] -= 1
|
||||
self._stats[STAT_CLIENTS_DISCONNECTED] += 1
|
||||
|
|
|
@ -36,8 +36,8 @@ implements one or more of these methods:
|
|||
- `async def on_broker_pre_shutdown() -> None`
|
||||
- `async def on_broker_post_shutdown() -> None`
|
||||
|
||||
- `async def on_broker_client_connected(self, client_id:str) -> None`
|
||||
- `async def on_broker_client_disconnected(self, client_id:str) -> None`
|
||||
- `async def on_broker_client_connected(self, client_id:str, client_session:Session) -> None`
|
||||
- `async def on_broker_client_disconnected(self, client_id:str, client_session:Session) -> None`
|
||||
|
||||
- `async def on_broker_client_subscribed(self, client_id: str, topic: str, qos: int) -> None`
|
||||
- `async def on_broker_client_unsubscribed(self, client_id: str, topic: str) -> None`
|
||||
|
|
Ładowanie…
Reference in New Issue