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

#pragma once

#include "export.h"

#include <memory>
#include <unordered_set>

namespace switchboard {

/**
 * @brief SwitchboardWebSocketServer is a WebSocket server that handles incoming WebSocket connections.
 * It processes JSON-RPC commands and manages WebSocket sessions.
 * This server is designed to work with the Switchboard SDK and provides a way to interact with Switchboard objects over WebSockets.
 */
class SWITCHBOARDSDK_EXPORT SwitchboardWebSocketServer {
public:
    /**
     * @brief Constructor for SwitchboardWebSocketServer.
     * @param port The port on which the WebSocket server will listen.
     * @param allowOrigin The list of origin.
     */
    explicit SwitchboardWebSocketServer(int port, const std::unordered_set<std::string>& allowOrigin);

    /**
     * @brief Destructor for SwitchboardWebSocketServer.
     */
    ~SwitchboardWebSocketServer();

    /**
     * @brief Starts the WebSocket server.
     */
    void start() const;

    /**
     * @brief Stops the WebSocket server.
     */
    void stop() const;

    /**
     * @brief Checks if the server is running.
     * @return True if the server is running, false otherwise.
     */
    [[nodiscard]] bool isRunning() const;

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

}
