Overview
Custom events are manually triggered by the TikTokLive SDK to provide connection lifecycle management and special interaction handling. These events are defined inTikTokLive/events/custom_events.py.
Connection Events
ConnectEvent
Triggered when the client successfully connects to a TikTok LIVE stream and receives the first payload from the Sign Server. Properties:unique_id(str) - The unique username of the streamerroom_id(int) - The room ID of the livestream
DisconnectEvent
Triggered when the client disconnects from a TikTok LIVE stream. Example:Stream Control Events
LiveEndEvent
Triggered when the livestream ends. Inherits fromControlEvent.
Example:
LivePauseEvent
Triggered when the livestream is paused by the streamer. Inherits fromControlEvent.
Example:
LiveUnpauseEvent
Triggered when a paused livestream resumes. Inherits fromControlEvent.
Example:
Social Interaction Events
FollowEvent
Triggered when a user follows the streamer during the livestream. Inherits fromSocialEvent.
Example:
ShareEvent
Triggered when a user shares the livestream. Inherits fromSocialEvent.
Properties:
users_joined(Optional[int]) - Number of people who joined the stream from the share
SuperFanEvent
Triggered for super fan interactions. This is a specializedBarrageEvent with its own class for clarity.
Example:
Special Events
WebsocketResponseEvent
Triggered for any event received from the WebSocket connection. This is the base event for all WebSocket messages. Example:UnknownEvent
Triggered when a Webcast message is received that is not yet tracked by TikTokLive. Inherits fromWebsocketResponseEvent.
Example:
Event Hierarchy
Custom events inherit from base proto events:Usage Tips
- ConnectEvent is ideal for initialization logic when connecting to a stream
- DisconnectEvent is useful for cleanup operations
- LiveEndEvent helps detect when a stream has finished
- UnknownEvent is helpful for debugging new TikTok features
Next Steps
- Explore Proto Events for interaction events
- See the Client Reference for connection configuration
- Learn about Event System Overview