1 parent
4a92d09e63
commit
45eb2cab42
12 files changed
+991
-162
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <PluginTypes.hpp>
|
||||
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace Echoion::Standalone
|
||||
{
|
||||
// Owns plugin-event callbacks across a dynamically loaded Core boundary.
|
||||
// quiesce() is a lifetime barrier: after it returns no callback object, nor
|
||||
// callback invocation, can still reference code from the old Core image.
|
||||
class EventCallbackGate final
|
||||
{
|
||||
public:
|
||||
void add(Api::EventCallback callback);
|
||||
void quiesce();
|
||||
void dispatch(const Api::PluginEvent& event);
|
||||
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::condition_variable cv_;
|
||||
std::vector<Api::EventCallback> callbacks_;
|
||||
std::size_t activeDispatches_{0};
|
||||
bool accepting_{true};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <Types.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
namespace Echoion::Standalone
|
||||
{
|
||||
struct ReleaseManifest {
|
||||
std::string version;
|
||||
std::filesystem::path executable;
|
||||
std::filesystem::path core;
|
||||
std::string executableSha256;
|
||||
std::string coreSha256;
|
||||
|
||||
[[nodiscard]] static Api::Result<ReleaseManifest>
|
||||
load(const std::filesystem::path& manifestPath);
|
||||
[[nodiscard]] Api::Result<void> validate() const;
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
// Implements Echoion's IPluginInterface against the native TeamSpeak UDP
|
||||
// protocol (EchoionProtocol) instead of the TS3 Client Plugin SDK. This is the
|
||||
// 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.
|
||||
|
||||
#include <PluginInterface.hpp>
|
||||
|
||||
#include "echoion/protocol/Identity.hpp"
|
||||
#include "echoion/protocol/TsClient.hpp"
|
||||
#include "echoion/standalone/EventCallbackGate.hpp"
|
||||
#include <Void/TeamSpeak/TeamSpeak.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <map>
|
||||
@@ -85,6 +85,14 @@ 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>
|
||||
@@ -98,23 +106,28 @@ namespace Echoion::Standalone
|
||||
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(const Protocol::ParsedCommand& parsed);
|
||||
void onTextMessage(const Protocol::CommandParams& params);
|
||||
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 Protocol::CommandParams& p,
|
||||
void upsertClientGroup(const Void::TeamSpeak::CommandFields& p,
|
||||
bool emitConnected);
|
||||
void refreshClient(const Protocol::CommandParams& params);
|
||||
void refreshClient(const Void::TeamSpeak::CommandFields& params);
|
||||
void loadInitialSnapshot();
|
||||
[[nodiscard]] Api::Result<void>
|
||||
commandResult(const Protocol::CommandResult& result) const;
|
||||
[[nodiscard]] Api::Result<void> commandResult(
|
||||
const Void::Result::Result<void, Void::TeamSpeak::Error>& result) const;
|
||||
|
||||
StandaloneSettings settings_;
|
||||
std::unique_ptr<Protocol::Identity> identity_;
|
||||
std::unique_ptr<Protocol::TsClient> client_;
|
||||
std::shared_ptr<Void::TeamSpeak::Identity> identity_;
|
||||
std::unique_ptr<Void::TeamSpeak::Client> client_;
|
||||
std::unique_ptr<AudioEncoder> encoder_;
|
||||
|
||||
Api::ServerConfig currentConfig_{};
|
||||
@@ -128,10 +141,13 @@ namespace Echoion::Standalone
|
||||
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_;
|
||||
|
||||
std::mutex cbMutex_;
|
||||
std::vector<Api::EventCallback> callbacks_;
|
||||
EventCallbackGate eventCallbacks_;
|
||||
};
|
||||
|
||||
} // namespace Echoion::Standalone
|
||||
Reference in new issue
Block a user