• JsonHandler
  • JsonHandler Class

    (nymeaserver::JsonHandler)

    This class represents an interface for developing a handler for the JSON-RPC API. More...

    Public Functions

    JsonHandler(QObject * parent = 0)
    bool hasMethod(const QString & methodName)
    QVariantMap introspect(QMetaMethod::MethodType type)
    virtual QString name() const = 0
    QPair<bool, QString> validateParams(const QString & methodName, const QVariantMap & params)
    QPair<bool, QString> validateReturns(const QString & methodName, const QVariantMap & returns)

    Signals

    void asyncReply(int id, const QVariantMap & params)

    Protected Functions

    JsonReply * createAsyncReply(const QString & method) const
    JsonReply * createReply(const QVariantMap & data) const
    void setDescription(const QString & methodName, const QString & description)
    void setParams(const QString & methodName, const QVariantMap & params)
    void setReturns(const QString & methodName, const QVariantMap & returns)
    QVariantMap statusToReply(DeviceManager::DeviceError status) const
    QVariantMap statusToReply(RuleEngine::RuleError status) const
    QVariantMap statusToReply(Logging::LoggingError status) const
    QVariantMap statusToReply(NymeaConfiguration::ConfigurationError status) const
    QVariantMap statusToReply(NetworkManager::NetworkManagerError status) const
    QVariantMap statusToReply(TagsStorage::TagError status) const

    Detailed Description

    This class represents an interface for developing a handler for the JSON-RPC API.

    See also JsonRPCServer and JsonReply.

    Member Function Documentation

    JsonHandler::JsonHandler(QObject * parent = 0)

    Constructs a new JsonHandler with the given parent.

    [signal] void JsonHandler::asyncReply(int id, const QVariantMap & params)

    This signal will be emitted when a reply with the given id and params is finished.

    [protected] JsonReply * JsonHandler::createAsyncReply(const QString & method) const

    Returns the pointer to an asynchronous new JsonReply with the given method.

    [protected] JsonReply * JsonHandler::createReply(const QVariantMap & data) const

    Returns the pointer to a new JsonReply with the given data.

    bool JsonHandler::hasMethod(const QString & methodName)

    Returns true if this JsonHandler has a method with the given methodName.

    QVariantMap JsonHandler::introspect(QMetaMethod::MethodType type)

    Returns a map with all supported methods, notifications and types for the given meta type.

    [pure virtual] QString JsonHandler::name() const

    Pure virtual method for a JSON RPC handler. Returns the namespace of the handler.

    [protected] void JsonHandler::setDescription(const QString & methodName, const QString & description)

    Sets the description of the method with the given methodName.

    [protected] void JsonHandler::setParams(const QString & methodName, const QVariantMap & params)

    Sets the params of the method with the given methodName.

    [protected] void JsonHandler::setReturns(const QString & methodName, const QVariantMap & returns)

    Sets the returns of the method with the given methodName.

    [protected] QVariantMap JsonHandler::statusToReply(DeviceManager::DeviceError status) const

    Returns the formated error map for the given status.

    See also DeviceManager::DeviceError.

    [protected] QVariantMap JsonHandler::statusToReply(RuleEngine::RuleError status) const

    Returns the formated error map for the given status.

    See also RuleEngine::RuleError.

    [protected] QVariantMap JsonHandler::statusToReply(Logging::LoggingError status) const

    Returns the formated error map for the given status.

    See also Logging::LoggingError.

    [protected] QVariantMap JsonHandler::statusToReply(NymeaConfiguration::ConfigurationError status) const

    Returns the formated error map for the given status.

    [protected] QVariantMap JsonHandler::statusToReply(NetworkManager::NetworkManagerError status) const

    Returns the formated error map for the given status.

    [protected] QVariantMap JsonHandler::statusToReply(TagsStorage::TagError status) const

    Returns the formated error map for the given status.

    QPair<bool, QString> JsonHandler::validateParams(const QString & methodName, const QVariantMap & params)

    Validates the given params for the given methodName. Returns the error string and false if the params are not valid.

    QPair<bool, QString> JsonHandler::validateReturns(const QString & methodName, const QVariantMap & returns)

    Validates the given returns for the given methodName. Returns the error string and false if the params are not valid.