//
//  SwitchboardJSONRPC.hpp
//  SwitchboardSDK
//
//  Copyright © 2026 Synervoz. All rights reserved.
//

#pragma once

#include "export.h"

#include <functional>
#include <memory>
#include <string>

namespace switchboard {

/**
 * SwitchboardJSONRPC class.
 * @brief Provides methods to process JSON-RPC commands.
 */
class SWITCHBOARDSDK_EXPORT SwitchboardJSONRPC {
public:

    /// Callback function type for handling events
    using Callback = std::function<void(const std::string&)>;

    /**
     * @brief Constructor for SwitchboardJSONRPC class.
     */
    SwitchboardJSONRPC();

    /**
     * @brief Destructor for SwitchboardJSONRPC class.
     */
    ~SwitchboardJSONRPC();

    /**
     * @brief Processes a JSON-RPC command and returns the response as a JSON string.
     *
     * @param command The JSON-RPC command to process.
     *
     * @return The response as a JSON string.
     */
    std::string processCommand(const std::string& command);

    /**
     * @brief Sets a callback function to be invoked for specific events.
     * 
     * @param callback The callback function to set.
     */
    void setEventCallback(const Callback& callback);

    /**
     * @brief Clears the currently set event callback function.
     */
    void clearEventCallback();

private:
    class Impl;
    std::unique_ptr<Impl> impl;
};

}
