WebhookClient class
#include <Jazz2/Multiplayer/WebhookClient.h>
Posts selected server events to a configured webhook.
Serializes server events into rich embed notifications and delivers them to the webhook URL from ServerConfiguration::Retry-After on HTTP 429) and every notification carries the server name, so multiple servers can be aggregated into a single channel. Which events are posted is selected by ServerConfiguration::
Public types
- struct LeaderboardEntry
- Single row of a leaderboard included in a webhook notification.
Constructors, destructors, conversion operators
- WebhookClient(NetworkManager* server)
- Creates an instance for a running server and starts the delivery thread.
- ~WebhookClient()
- Flushes still pending events and stops the delivery thread.
- WebhookClient(const WebhookClient&) deleted
Public functions
- auto operator=(const WebhookClient&) -> WebhookClient& deleted
- auto IsEventEnabled(WebhookEventType type) const -> bool
- Returns
trueif the specified event should be posted to the webhook. - void UpdateConfiguration()
- Applies webhook-related changes after the server configuration has been reloaded.
- void OnServerStarted()
- Called when the server has been started.
- void OnServerStopping()
- Called when the server is about to be stopped.
-
void OnPlayerConnected(StringView playerName,
std::
uint32_t playerCount, std:: uint32_t maxPlayerCount) - Called when a player successfully joined the server.
-
void OnPlayerDisconnected(StringView playerName,
Reason reason,
std::
uint32_t playerCount, std:: uint32_t maxPlayerCount) - Called when a player left the server, including moderation actions described by
reason. -
void OnLevelChanged(StringView levelDisplayName,
MpGameMode gameMode,
bool reforgedGameplay,
bool elimination,
StringView targetLabel,
std::
uint32_t targetValue, std:: int32_t playlistIndex, std:: int32_t playlistSize) - Called when a level has been loaded,
playlistSizeis0if no playlist is active. - void OnRoundStarted(StringView levelDisplayName, MpGameMode gameMode)
- Called when the round countdown finished and the round is running.
- void OnRoundEnded(StringView winnerName, StringView levelDisplayName, MpGameMode gameMode, ArrayView<const LeaderboardEntry> standings = {}, StringView scoreLabel = {})
- Called when the round ended,
winnerNameis empty if the round ended in a draw. - void OnRoundEndedWithTeamWinner(StringView teamName, StringView levelDisplayName, MpGameMode gameMode, ArrayView<const LeaderboardEntry> teamMembers = {}, StringView scoreLabel = {})
- Called when the round ended with a winning team,
teamMembersare listed in the notification. -
void OnChampionshipEnded(StringView championName,
std::
uint32_t points, ArrayView<const LeaderboardEntry> standings = {}) - Called when a player won the championship,
standingsare the final championship rankings. - void OnChatMessage(StringView playerName, StringView message, bool isAdmin)
- Called when a chat message has been sent.
- void OnPlayerRoasted(StringView playerName, StringView attackerName)
- Called when a player was roasted,
attackerNameis empty if roasted by the environment. -
void OnPlayerLapFinished(StringView playerName,
float lapSecs,
std::
uint32_t lap, std:: uint32_t totalLaps) - Called when a player finished a lap (Race).
-
void OnFlagCaptured(StringView playerName,
StringView teamName,
StringView flagTeamName,
std::
uint32_t captures, std:: uint32_t totalCaptures) - Called when a team captured a flag (Capture The Flag).
Function documentation
void Jazz2:: Multiplayer:: WebhookClient:: OnLevelChanged(StringView levelDisplayName,
MpGameMode gameMode,
bool reforgedGameplay,
bool elimination,
StringView targetLabel,
std:: uint32_t targetValue,
std:: int32_t playlistIndex,
std:: int32_t playlistSize)
Called when a level has been loaded, playlistSize is 0 if no playlist is active.
targetLabel and targetValue describe the win condition of the round (e.g. "Kills" and 10); pass a zero value to omit it, for example when the target is auto-weighted.
void Jazz2:: Multiplayer:: WebhookClient:: OnRoundEnded(StringView winnerName,
StringView levelDisplayName,
MpGameMode gameMode,
ArrayView<const LeaderboardEntry> standings = {},
StringView scoreLabel = {})
Called when the round ended, winnerName is empty if the round ended in a draw.
standings are the final rankings (best first) rendered as a leaderboard, scoreLabel is their plural unit (e.g. "kills"). Both can be empty in game modes without meaningful standings.