mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-30 22:59:51 +02:00
Pass complete Settings struct around
This commit is contained in:
parent
964801896a
commit
c112058998
18 changed files with 584 additions and 140 deletions
|
@ -20,6 +20,7 @@
|
|||
|
||||
// local headers
|
||||
#include "authinfo.hpp"
|
||||
#include "server_settings.hpp"
|
||||
|
||||
// 3rd party headers
|
||||
|
||||
|
@ -37,10 +38,14 @@ class StreamSession;
|
|||
class ControlMessageReceiver
|
||||
{
|
||||
public:
|
||||
using ResponseHander = std::function<void(const std::string& response)>;
|
||||
/// Response callback function for requests
|
||||
using ResponseHandler = std::function<void(const std::string& response)>;
|
||||
// TODO: rename, error handling
|
||||
virtual void onMessageReceived(std::shared_ptr<ControlSession> session, const std::string& message, const ResponseHander& response_handler) = 0;
|
||||
/// Called when a comtrol message @p message is received by @p session, response is written to @p response_handler
|
||||
virtual void onMessageReceived(std::shared_ptr<ControlSession> session, const std::string& message, const ResponseHandler& response_handler) = 0;
|
||||
/// Called when a comtrol session is created
|
||||
virtual void onNewSession(std::shared_ptr<ControlSession> session) = 0;
|
||||
/// Called when a stream session is created
|
||||
virtual void onNewSession(std::shared_ptr<StreamSession> session) = 0;
|
||||
};
|
||||
|
||||
|
@ -55,18 +60,22 @@ class ControlSession : public std::enable_shared_from_this<ControlSession>
|
|||
{
|
||||
public:
|
||||
/// ctor. Received message from the client are passed to ControlMessageReceiver
|
||||
ControlSession(ControlMessageReceiver* receiver) : message_receiver_(receiver)
|
||||
ControlSession(ControlMessageReceiver* receiver, const ServerSettings& settings) : authinfo(settings), message_receiver_(receiver)
|
||||
{
|
||||
}
|
||||
virtual ~ControlSession() = default;
|
||||
/// Start the control session
|
||||
virtual void start() = 0;
|
||||
/// Stop the control session
|
||||
virtual void stop() = 0;
|
||||
|
||||
/// Sends a message to the client (asynchronous)
|
||||
virtual void sendAsync(const std::string& message) = 0;
|
||||
|
||||
std::optional<AuthInfo> authinfo;
|
||||
/// Authentication info attached to this session
|
||||
AuthInfo authinfo;
|
||||
|
||||
protected:
|
||||
/// The control message receiver
|
||||
ControlMessageReceiver* message_receiver_;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue