tribler.core.restapi.events_endpoint
Attributes
Classes
A message fit for the GUI, usually forwarded from the Notifier. |
|
Important events in Tribler are returned over the events endpoint. This connection is held open. Each event is |
Module Contents
- tribler.core.restapi.events_endpoint.topics_to_send_to_gui
- class tribler.core.restapi.events_endpoint.MessageDict
Bases:
TypedDictA message fit for the GUI, usually forwarded from the Notifier.
- class tribler.core.restapi.events_endpoint.EventsEndpoint(notifier: tribler.core.notifier.Notifier, public_key: str | None = None)
Bases:
tribler.core.restapi.rest_endpoint.RESTEndpointImportant events in Tribler are returned over the events endpoint. This connection is held open. Each event is pushed over this endpoint in the form of a JSON dictionary. Each JSON dictionary contains a type field that indicates the type of the event. Individual events are separated by a newline character.
- path = '/api/events'
- shutdown_event
- public_key = None
- notifier
- queue: asyncio.Queue[MessageDict]
- on_notification(topic: tribler.core.notifier.Notification, **kwargs) None
Callback for when a notification is received. Check if we should forward it to the GUI.
- on_circuit_removed(circuit: ipv8.messaging.anonymization.tunnel.Circuit, additional_info: str) None
Special handler for circuit removal notifications.
The original notification contains non-JSON-serializable argument, so we send another one to GUI.
- initial_message() MessageDict
Create the initial message to announce to the GUI.
- error_message(reported_error: Exception) MessageDict
Create an error message for the GUI.
- encode_message(message: MessageDict) bytes
Use JSON to dump the given message to bytes.
- should_skip_message(message: MessageDict) bool
Returns True if EventsEndpoint should skip sending message to GUI due to a shutdown or no connection to GUI. Issue an appropriate warning if the message cannot be sent.
- send_event(message: MessageDict) None
Put event message to a queue to be sent to GUI.
- async _write_data(message: MessageDict) None
Write data over the event socket if it’s open.
- async get_info(request: aiohttp.web_request.Request) tribler.core.restapi.rest_endpoint.RESTResponse
Get the general info of the events endpoint.
- async get_events(request: aiohttp.web_request.Request) aiohttp.web.StreamResponse
A GET request to this endpoint will open the event connection.
Example request:
curl -X GET http://localhost:20100/events