QJsonChannelCore
QJsonChannelMessage Class Reference

Representation of JSON-RPC message. More...

#include <QJsonChannelMessage.h>

Collaboration diagram for QJsonChannelMessage:
Collaboration graph

Public Types

enum  Type {
  Invalid, Request, Response, Notification,
  Error, Discrovery
}
 Message types. More...
 

Public Member Functions

 QJsonChannelMessage ()
 
 QJsonChannelMessage (const QJsonChannelMessage &other)
 
QJsonChannelMessageoperator= (const QJsonChannelMessage &other)
 
 ~QJsonChannelMessage ()
 
void swap (QJsonChannelMessage &other)
 
QJsonChannelMessage createResponse (const QJsonValue &result) const
 Create a Response object. More...
 
QJsonChannelMessage createErrorResponse (QJsonChannel::ErrorCode code, const QString &message=QString(), const QJsonValue &data=QJsonValue()) const
 Create a Error Response object. More...
 
QJsonChannelMessage::Type type () const
 Returns message type. More...
 
bool isValid () const
 Verifies if the message has valid type. More...
 
int id () const
 Returns message Id. More...
 
QString serviceName () const
 Returns requested service name (of Request message) More...
 
QString method () const
 Returns requested method name (of Request message) More...
 
QJsonValue params () const
 Returns the Request params (of Request message) More...
 
QJsonValue result () const
 Returns Response values (of response message) More...
 
int errorCode () const
 Returns error code (of Error message) More...
 
QString errorMessage () const
 Returns error message (of Error message) More...
 
QJsonValue errorData () const
 Returns error data (of Error message) More...
 
QJsonObject toObject () const
 Converts the message to JSON object. More...
 
QByteArray toJson () const
 Converts the message to string data. More...
 
bool operator== (const QJsonChannelMessage &message) const
 
bool operator!= (const QJsonChannelMessage &message) const
 

Static Public Member Functions

static QJsonChannelMessage createRequest (const QString &method, const QJsonArray &params=QJsonArray())
 Create a Request for a positional method call. More...
 
static QJsonChannelMessage createRequest (const QString &method, const QJsonValue &param)
 Create a Request for a single argument method call. More...
 
static QJsonChannelMessage createRequest (const QString &method, const QJsonObject &namedParameters)
 Create a Request for a name method call. More...
 
static QJsonChannelMessage createNotification (const QString &method, const QJsonArray &params=QJsonArray())
 Create a Notification for a positional method call. More...
 
static QJsonChannelMessage createNotification (const QString &method, const QJsonValue &param)
 Create a Notification for a single argument method call. More...
 
static QJsonChannelMessage createNotification (const QString &method, const QJsonObject &namedParameters)
 Create a Notification for a name method call. More...
 
static QJsonChannelMessage fromObject (const QJsonObject &object)
 Converts a JSON to a JSON-RPC message. More...
 
static QJsonChannelMessage fromJson (const QByteArray &data)
 Convert a string data to a JSON-RPC message. More...
 

Detailed Description

Representation of JSON-RPC message.

Definition at line 18 of file QJsonChannelMessage.h.

Member Enumeration Documentation

◆ Type

Message types.

Enumerator
Invalid 

Invalid message.

Request 

Request message.

Response 

Response message.

Notification 

Notification message.

Error 

Error Response message.

Discrovery 

Discrovery Request message.

Definition at line 33 of file QJsonChannelMessage.h.

Constructor & Destructor Documentation

◆ QJsonChannelMessage() [1/2]

QJsonChannelMessage::QJsonChannelMessage ( )

◆ QJsonChannelMessage() [2/2]

QJsonChannelMessage::QJsonChannelMessage ( const QJsonChannelMessage other)

◆ ~QJsonChannelMessage()

QJsonChannelMessage::~QJsonChannelMessage ( )

Member Function Documentation

◆ operator=()

QJsonChannelMessage& QJsonChannelMessage::operator= ( const QJsonChannelMessage other)

◆ swap()

void QJsonChannelMessage::swap ( QJsonChannelMessage other)
inline

Definition at line 25 of file QJsonChannelMessage.h.

◆ createRequest() [1/3]

static QJsonChannelMessage QJsonChannelMessage::createRequest ( const QString &  method,
const QJsonArray &  params = QJsonArray() 
)
static

Create a Request for a positional method call.

Parameters
methodMethod name
paramsArguments values array
Returns
QJsonChannelMessage

◆ createRequest() [2/3]

static QJsonChannelMessage QJsonChannelMessage::createRequest ( const QString &  method,
const QJsonValue &  param 
)
static

Create a Request for a single argument method call.

Parameters
methodMethod name
paramArgument value
Returns
QJsonChannelMessage

◆ createRequest() [3/3]

static QJsonChannelMessage QJsonChannelMessage::createRequest ( const QString &  method,
const QJsonObject &  namedParameters 
)
static

Create a Request for a name method call.

Parameters
methodMethod name
paramsArguments names and values as JSON object
Returns
QJsonChannelMessage

◆ createNotification() [1/3]

static QJsonChannelMessage QJsonChannelMessage::createNotification ( const QString &  method,
const QJsonArray &  params = QJsonArray() 
)
static

Create a Notification for a positional method call.

Parameters
methodMethod name
paramsArguments values array
Returns
QJsonChannelMessage

◆ createNotification() [2/3]

static QJsonChannelMessage QJsonChannelMessage::createNotification ( const QString &  method,
const QJsonValue &  param 
)
static

Create a Notification for a single argument method call.

Parameters
methodMethod name
paramArgument value
Returns
QJsonChannelMessage

◆ createNotification() [3/3]

static QJsonChannelMessage QJsonChannelMessage::createNotification ( const QString &  method,
const QJsonObject &  namedParameters 
)
static

Create a Notification for a name method call.

Parameters
methodMethod name
paramsArguments names and values as JSON object
Returns
QJsonChannelMessage

◆ createResponse()

QJsonChannelMessage QJsonChannelMessage::createResponse ( const QJsonValue &  result) const

Create a Response object.

Parameters
resultValue of the call result
Returns
QJsonChannelMessage

◆ createErrorResponse()

QJsonChannelMessage QJsonChannelMessage::createErrorResponse ( QJsonChannel::ErrorCode  code,
const QString &  message = QString(),
const QJsonValue &  data = QJsonValue() 
) const

Create a Error Response object.

Parameters
codeError code
messageError message
dataAssociate data
Returns
QJsonChannelMessage

◆ type()

QJsonChannelMessage::Type QJsonChannelMessage::type ( ) const

Returns message type.

Returns
QJsonChannelMessage::Type

◆ isValid()

bool QJsonChannelMessage::isValid ( ) const

Verifies if the message has valid type.

Returns
true If the type is valid
false If the typie is QJsonChannelMessage::Type::Invalid

◆ id()

int QJsonChannelMessage::id ( ) const

Returns message Id.

Returns
int message Id

◆ serviceName()

QString QJsonChannelMessage::serviceName ( ) const

Returns requested service name (of Request message)

Returns
QString

◆ method()

QString QJsonChannelMessage::method ( ) const

Returns requested method name (of Request message)

Returns
QString

◆ params()

QJsonValue QJsonChannelMessage::params ( ) const

Returns the Request params (of Request message)

Returns
QJsonValue

◆ result()

QJsonValue QJsonChannelMessage::result ( ) const

Returns Response values (of response message)

Returns
QJsonValue

◆ errorCode()

int QJsonChannelMessage::errorCode ( ) const

Returns error code (of Error message)

Returns
int

◆ errorMessage()

QString QJsonChannelMessage::errorMessage ( ) const

Returns error message (of Error message)

Returns
QString

◆ errorData()

QJsonValue QJsonChannelMessage::errorData ( ) const

Returns error data (of Error message)

Returns
QJsonValue

◆ toObject()

QJsonObject QJsonChannelMessage::toObject ( ) const

Converts the message to JSON object.

Returns
QJsonObject

◆ fromObject()

static QJsonChannelMessage QJsonChannelMessage::fromObject ( const QJsonObject &  object)
static

Converts a JSON to a JSON-RPC message.

Parameters
object
Returns
QJsonChannelMessage

◆ toJson()

QByteArray QJsonChannelMessage::toJson ( ) const

Converts the message to string data.

Returns
QByteArray

◆ fromJson()

static QJsonChannelMessage QJsonChannelMessage::fromJson ( const QByteArray &  data)
static

Convert a string data to a JSON-RPC message.

Parameters
dataString data
Returns
QJsonChannelMessage

◆ operator==()

bool QJsonChannelMessage::operator== ( const QJsonChannelMessage message) const

◆ operator!=()

bool QJsonChannelMessage::operator!= ( const QJsonChannelMessage message) const
inline

Definition at line 216 of file QJsonChannelMessage.h.


The documentation for this class was generated from the following file: