Managers
Các manager trong SDK chịu trách nhiệm cho authentication state, WebSocket transport, channel operations, và event dispatch.
SessionManager
Source: mezon/managers/session.py
Responsibility
- Authenticate with
MezonApi - Hold the active
Session
Main methods
authenticate(...) calls the Mezon auth API and returns a Session object.
SocketManager
Source: mezon/managers/socket.py
Responsibility
- Own the low-level socket adapter
- Connect/reconnect using authenticated sessions
- Join clans and DM channels after login
- Write chat, ephemeral, update, delete, and reaction payloads
Main methods
await client.socket_manager.connect(session)
await client.socket_manager.connect_socket(session.token)
await client.socket_manager.write_chat_message(...)
await client.socket_manager.write_ephemeral_message(...)
await client.socket_manager.update_chat_message(...)
await client.socket_manager.write_message_reaction(...)
ChannelManager
Source: mezon/managers/channel.py
Responsibility
- Channel-related API helpers
- DM channel creation and initialization
You usually interact with it indirectly through client.channels, client.users, or User.send_dm_message(...).
EventManager
Source: mezon/managers/event.py
Responsibility
- Register handlers with
on(...) - Dispatch incoming realtime events to user and default handlers
In day-to-day usage you normally call convenience methods on MezonClient, for example:
client.on_channel_message(handler)
client.on_message_button_clicked(handler)
client.on_notification(handler)
CacheManager
Source: mezon/managers/cache.py
Responsibility
- In-memory cache with optional async fetcher
- Used by
client.clans,client.channels,client.users, andchannel.messages
Usage pattern
Use fetch(...) when loading may be required. Use get(...) only when you expect the object to already be present in memory.