Initializes a client for listening to various Donation Alerts events.
Configuration required for setting up the client, including user information, an API client for server communication, and optional logger options.
Readonly
onFires when the client establishes a connection with Centrifugo server.
Readonly
onFires when the client disconnects from the Centrifugo server.
Client ID assigned by the Centrifugo server.
Returns null
if the client is not connected.
Indicates whether the client is connected to the Centrifugo server.
true
if the client is connected; otherwise false
.
Unique identifier of the user associated with this client.
Establishes a connection to the Centrifugo server.
Specifies whether existing listeners should be restored after connection.
Defaults to true
.
Closes the connection to the Centrifugo server.
Indicates whether all active listeners should be removed on disconnect.
If set to false
, the listeners will be restored on the next connection.
Default to false
.
Subscribes to donation events from Donation Alerts.
A function invoked whenever a donation event is received. The callback receives an instance of DonationAlertsDonationEvent.
An EventsListener instance that manages the subscription.
Subscribes to goal update events from Donation Alerts.
A function invoked whenever a goal update event is received. The callback receives an instance of DonationAlertsGoalUpdateEvent.
An EventsListener instance that manages the subscription.
Subscribes to poll update events from Donation Alerts.
A function invoked whenever a poll update event is received. The callback receives an instance of DonationAlertsPollUpdateEvent.
An EventsListener instance that manages the subscription.
Re-establishes the connection to the Centrifugo server.
Indicates whether all listeners should be removed during reconnection.
If false
, all listeners will be restored automatically after reconnection.
Defaults to false
.
Unsubscribes and removes a listener for a specific channel.
The EventsListener instance to be removed.
Client for managing and subscribing to Donation Alerts events.
This class provides a WebSocket-based interface for real-time interaction with the Donation Alerts platform. It connects to its Centrifugo WebSocket server, enabling receiving notifications about donations, goal updates, and poll updates.
Designed for single-user use cases, it supports managing connection states (connect, disconnect, reconnect) and subscribing to or unsubscribing from specific event types.