1 parent
45eb2cab42
commit
8aa968eb9f
3 files changed
+922
-616
No files matched your search
@@ -1,10 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// Implements Echoion's IPluginInterface against the native TeamSpeak UDP
|
||||
// protocol through VoidTeamspeak instead of the TS3 Client Plugin SDK. This is the
|
||||
// single seam that lets the whole Core run as a standalone application: Core
|
||||
// only ever talks to IPluginInterface, so swapping this implementation in for
|
||||
// the plugin drops the TeamSpeak-client dependency entirely.
|
||||
// Implements Echoion's host interface by adapting VoidTeamspeak's typed client
|
||||
// operations and events. TeamSpeak protocol details remain inside
|
||||
// VoidTeamspeak; Core only sees the host-neutral Echoion API contract.
|
||||
|
||||
#include <PluginInterface.hpp>
|
||||
|
||||
@@ -63,12 +61,42 @@ namespace Echoion::Standalone
|
||||
uint64_t channelId) override;
|
||||
Api::Result<void> kickClient(uint64_t clientId,
|
||||
const std::string& reason) override;
|
||||
Api::Result<void>
|
||||
kickClientFromChannel(uint64_t clientId,
|
||||
const std::string& reason) override;
|
||||
Api::Result<void> banClient(uint64_t clientId,
|
||||
uint64_t durationSeconds,
|
||||
const std::string& reason) override;
|
||||
[[nodiscard]] Api::Result<std::vector<Api::BanInfo>>
|
||||
getBans() override;
|
||||
Api::Result<void> unban(uint64_t banId) override;
|
||||
|
||||
// Channels
|
||||
[[nodiscard]] Api::Result<std::vector<Api::ChannelInfo>>
|
||||
getChannels() const override;
|
||||
[[nodiscard]] Api::Result<std::optional<Api::ChannelInfo>>
|
||||
getChannel(uint64_t channelId) const override;
|
||||
Api::Result<uint64_t> createChannel(
|
||||
const Api::ChannelCreateOptions& options) override;
|
||||
Api::Result<void>
|
||||
editChannel(uint64_t channelId,
|
||||
const Api::ChannelEditOptions& options) override;
|
||||
Api::Result<void> reorderChannel(uint64_t channelId,
|
||||
uint64_t parentId,
|
||||
uint64_t orderAfterId) override;
|
||||
Api::Result<void> deleteChannel(uint64_t channelId,
|
||||
bool force) override;
|
||||
|
||||
[[nodiscard]] Api::Result<std::vector<Api::ServerGroupInfo>>
|
||||
getServerGroups() override;
|
||||
Api::Result<void>
|
||||
addClientToServerGroup(uint64_t groupId,
|
||||
uint64_t clientDatabaseId) override;
|
||||
Api::Result<void>
|
||||
removeClientFromServerGroup(uint64_t groupId,
|
||||
uint64_t clientDatabaseId) override;
|
||||
[[nodiscard]] Api::Result<Api::ServerInfo>
|
||||
getTeamSpeakServerInfo() override;
|
||||
|
||||
// Messaging
|
||||
Api::Result<void>
|
||||
@@ -85,14 +113,6 @@ namespace Echoion::Standalone
|
||||
sendAudioData(const std::span<const short>& data) override;
|
||||
Api::Result<void>
|
||||
setWhisperList(const std::vector<uint64_t>& clientIds) override;
|
||||
[[nodiscard]] Api::Result<AudioStreamId>
|
||||
createAudioStream(const AudioStreamOptions& options) override;
|
||||
Api::Result<void> destroyAudioStream(AudioStreamId id) override;
|
||||
Api::Result<void> sendAudioDataToStream(
|
||||
AudioStreamId id, const std::span<const short>& data) override;
|
||||
Api::Result<void> setAudioStreamRecipients(
|
||||
AudioStreamId id,
|
||||
const std::vector<uint64_t>& recipients) override;
|
||||
|
||||
// Connection
|
||||
Api::Result<void>
|
||||
@@ -102,28 +122,22 @@ namespace Echoion::Standalone
|
||||
Api::Result<void> reconnect() override;
|
||||
|
||||
// Events
|
||||
void
|
||||
registerEventCallback(const Api::EventCallback& cb) override;
|
||||
void
|
||||
unregisterEventCallback(const Api::EventCallback& cb) override;
|
||||
// Prevent new event dispatches, release registered callbacks and wait
|
||||
// until every callback already in flight has returned. The host must
|
||||
// call this before unloading code that owns an event callback.
|
||||
void registerEventCallback(const Api::EventCallback& cb) override;
|
||||
void unregisterEventCallback(const Api::EventCallback& cb) override;
|
||||
// Prevent new event dispatches, release registered callbacks and
|
||||
// wait until every callback already in flight has returned. The
|
||||
// host must call this before unloading code that owns an event
|
||||
// callback.
|
||||
void quiesceEventCallbacks();
|
||||
|
||||
private:
|
||||
|
||||
void wireCallbacks();
|
||||
void onCommand(std::string_view name,
|
||||
const std::vector<Void::TeamSpeak::CommandFields>& records);
|
||||
void onTextMessage(const Void::TeamSpeak::CommandFields& params);
|
||||
void broadcast(const Api::PluginEvent& event);
|
||||
void upsertClientGroup(const Void::TeamSpeak::CommandFields& p,
|
||||
bool emitConnected);
|
||||
void refreshClient(const Void::TeamSpeak::CommandFields& params);
|
||||
void loadInitialSnapshot();
|
||||
[[nodiscard]] Api::Result<void> commandResult(
|
||||
const Void::Result::Result<void, Void::TeamSpeak::Error>& result) const;
|
||||
const Void::Result::Result<void, Void::TeamSpeak::Error>&
|
||||
result) const;
|
||||
|
||||
StandaloneSettings settings_;
|
||||
std::shared_ptr<Void::TeamSpeak::Identity> identity_;
|
||||
@@ -134,17 +148,14 @@ namespace Echoion::Standalone
|
||||
std::atomic<bool> initialized_{false};
|
||||
|
||||
mutable std::mutex mirrorMutex_;
|
||||
std::map<uint64_t, Api::ClientInfo> clients_;
|
||||
std::map<uint64_t, Api::ChannelInfo> channels_;
|
||||
std::map<uint64_t, Void::TeamSpeak::RemoteClient> clients_;
|
||||
std::map<uint64_t, Void::TeamSpeak::Channel> channels_;
|
||||
std::optional<Void::TeamSpeak::ServerInfo> serverInfo_;
|
||||
std::map<uint64_t, std::string> clientIps_;
|
||||
std::map<uint64_t, std::string> avatarHashes_;
|
||||
std::map<uint64_t, std::string> avatarUrls_;
|
||||
std::map<uint64_t, std::string> avatarPaths_;
|
||||
std::vector<uint64_t> whisperList_;
|
||||
struct AudioStreamRuntime;
|
||||
std::map<AudioStreamId, std::shared_ptr<AudioStreamRuntime>> audioStreams_;
|
||||
std::atomic<AudioStreamId> nextAudioStreamId_{1};
|
||||
mutable std::mutex audioStreamsMutex_;
|
||||
std::jthread snapshotThread_;
|
||||
|
||||
EventCallbackGate eventCallbacks_;
|
||||
|
||||
Reference in new issue
Block a user