SystemControllerConnection

SystemControllerConnection

An implementation of the ISystemControllerInterface for a System controller residing in a remote server. The connection to the server uses a Websocket.

#include <SystemControllerConnection.h>

Inherits from ISystemControllerInterface

Public Classes

Name
structSettings
Settings for a SystemControllerConnection.

Public Types

Name
enum class uint32_tComponentType { kIngest, kMediaReceiver, kMediaStreamer, kControlDataReceiver, kControlDataSender}
Enumeration of component types the component using this SystemControllerConnection can tell the System Controller to be seen as.

Public Functions

Name
SystemControllerConnection()
~SystemControllerConnection() override
boolconfigure(const Settings & settings, const std::shared_ptr< ISystemControllerInterface > & parentInterface =nullptr)
Configure this connection. This method should be called before calling.
virtual boolconnect() override
Connect to the server using the settings set with the.
virtual boolisConnected() const override
virtual std::stringgetUUID() const override
virtual ResponsesendRequest(const std::string & request, const nlohmann::json & parameters) override
Send a JSON object to the system controller server and awaits the response.
virtual booldisconnect() override
Disconnect from the server.
virtual boolregisterRequestCallback(const Callbacks & callbacks) override
Register callbacks to call when getting requests from the server or the server connection is lost.
virtual boolhasParent() const override
virtual std::shared_ptr< ISystemControllerInterface >getParentInterface() const override
SystemControllerConnection(SystemControllerConnection const & ) =delete
SystemControllerConnection(SystemControllerConnection && ) =delete
SystemControllerConnection &operator=(SystemControllerConnection const & ) =delete
SystemControllerConnection &operator=(SystemControllerConnection && ) =delete

Additional inherited members

Public Classes inherited from ISystemControllerInterface

Name
structCallbacks
A struct containing the callbacks that needs to be registered by the component using this interface.
structResponse
A response to a request, consists of a status code and an (optional) parameters JSON object.

Public Types inherited from ISystemControllerInterface

Name
enum class uint32_tStatusCode { SUCCESS, TOO_MANY_REQUESTS, UUID_ALREADY_REGISTERED, FORMAT_ERROR, ALREADY_CONFIGURED, OUT_OF_RESOURCES, NOT_FOUND, INTERNAL_ERROR, CONNECTION_FAILED, TIMEOUT_EXCEEDED, KEY_MISMATCH, UNKNOWN_REQUEST, MALFORMED_REQUEST, ALREADY_IN_USE}
Status codes used in JSON response messages for Websockets. These are starting at 3000 since the 1000 - 2000 range is taken up by the Spec: https://datatracker.ietf.org/doc/html/rfc6455#section-7.4.1.

Public Functions inherited from ISystemControllerInterface

Name
virtual~ISystemControllerInterface() =default
Virtual destructor.

Public Types Documentation

enum ComponentType

EnumeratorValueDescription
kIngest
kMediaReceiver
kMediaStreamer
kControlDataReceiver
kControlDataSender

Enumeration of component types the component using this SystemControllerConnection can tell the System Controller to be seen as.

Public Functions Documentation

function SystemControllerConnection

SystemControllerConnection()

function ~SystemControllerConnection

~SystemControllerConnection() override

function configure

bool configure(
    const Settings & settings,
    const std::shared_ptr< ISystemControllerInterface > & parentInterface =nullptr
)

Configure this connection. This method should be called before calling.

Parameters:

  • settings The settings to use when connecting to the server
  • parentInterface Optional parent interface that this interface is a child of. Setting this to nullptr means that this interface does not have a parent interface

See: connect.

Return: True if successfully configured, false otherwise

function connect

virtual bool connect() override

Connect to the server using the settings set with the.

See: configure method.

Return: True if connection was successful, false otherwise

Reimplements: ISystemControllerInterface::connect

function isConnected

virtual bool isConnected() const override

Return: True if this class is connected to the server, false otherwise

Reimplements: ISystemControllerInterface::isConnected

function getUUID

virtual std::string getUUID() const override

Return: The UUID of this interface to the System controller

Reimplements: ISystemControllerInterface::getUUID

function sendRequest

virtual Response sendRequest(
    const std::string & request,
    const nlohmann::json & parameters
) override

Send a JSON object to the system controller server and awaits the response.

Parameters:

  • request The name of the request command
  • parameters The parameters part of the JSON message

Return: The response from the controller

Note: The status code might be TIMEOUT in case no response was received within the timeframe

Reimplements: ISystemControllerInterface::sendRequest

function disconnect

virtual bool disconnect() override

Disconnect from the server.

Return: True if successfully disconnected, false on internal error

Reimplements: ISystemControllerInterface::disconnect

function registerRequestCallback

virtual bool registerRequestCallback(
    const Callbacks & callbacks
) override

Register callbacks to call when getting requests from the server or the server connection is lost.

Parameters:

  • callbacks The callbacks to set

Return: True if successfully registered, false if a callback is not set, or if already connected to the server

Reimplements: ISystemControllerInterface::registerRequestCallback

function hasParent

virtual bool hasParent() const override

Return: True if this component has a parent ISystemControllerInterface, false otherwise

Reimplements: ISystemControllerInterface::hasParent

function getParentInterface

virtual std::shared_ptr< ISystemControllerInterface > getParentInterface() const override

Return: A pointer to parent’s ISystemControllerInterface, if any. Returns nullptr in case there is no parent

Reimplements: ISystemControllerInterface::getParentInterface

function SystemControllerConnection

SystemControllerConnection(
    SystemControllerConnection const & 
) =delete

function SystemControllerConnection

SystemControllerConnection(
    SystemControllerConnection && 
) =delete

function operator=

SystemControllerConnection & operator=(
    SystemControllerConnection const & 
) =delete

function operator=

SystemControllerConnection & operator=(
    SystemControllerConnection && 
) =delete

Updated on 2022-06-22 at 16:53:25 +0200