|
AvogadroApp
|
#include <avogadro/rpc/message.h>
Public Types | |
| enum | MessageType { Request = 0x1 , Notification = 0x2 , Response = 0x4 , Error = 0x8 , Raw = 0x10 , Invalid = 0x20 } |
Public Member Functions | |
| Message (Connection *conn=nullptr, EndpointIdType endpoint_=EndpointIdType()) | |
| Message (MessageType type_, Connection *conn=nullptr, EndpointIdType endpoint_=EndpointIdType()) | |
| Message (const QJsonObject &rawJson, Connection *conn=nullptr, EndpointIdType endpoint_=EndpointIdType()) | |
| Message (const Message &other) | |
| Message & | operator= (const Message &other) |
| MessageType | type () const |
| QString | method () const |
| void | setMethod (const QString &m) |
| QJsonValue | params () const |
| QJsonValue & | paramsRef () |
| void | setParams (const QJsonArray &p) |
| void | setParams (const QJsonObject &p) |
| QJsonValue | result () const |
| QJsonValue & | resultRef () |
| void | setResult (const QJsonValue &r) |
| int | errorCode () const |
| void | setErrorCode (int e) |
| QString | errorMessage () const |
| void | setErrorMessage (const QString &e) |
| QJsonValue | errorData () const |
| QJsonValue & | errorDataRef () |
| void | setErrorData (const QJsonValue &e) |
| MessageIdType | id () const |
| Connection * | connection () const |
| void | setConnection (Connection *c) |
| EndpointIdType | endpoint () const |
| void | setEndpoint (const EndpointIdType &e) |
| QJsonObject | toJsonObject () const |
| PacketType | toJson () const |
| bool | send () |
| Message | generateResponse () const |
| Message | generateErrorResponse () const |
| bool | parse () |
| bool | parse (Message &errorMessage_) |
Protected Member Functions | |
| void | setId (const MessageIdType &i) |
The Message class encapsulates a single JSON-RPC transmission.
The Message class provides an interface to construct, interpret, and manipulate JSON-RPC messages.
There are four types of valid JSON-RPC messages: Requests, notifications, responses, and errors. The type() method can be used to determine a given Message's MessageType.
| enum MessageType |
Flags representing different types of JSON-RPC messages.
| Enumerator | |
|---|---|
| Request | A JSON-RPC request, with id, method, and params attributes. |
| Notification | A JSON-RPC notification, with method and params attributes. |
| Response | A JSON-RPC response, with id, method, and result attributes. |
| Error | A JSON-RPC error, with id, method, and errorCode, errorMessage, and errorData attributes. |
| Raw | This MessageType indicates that this Message holds a raw QJsonObject that has not been interpreted. Call parse() to convert this Message into an appropriate type. |
| Invalid | This Message is invalid. |
| Message | ( | Connection * | conn = nullptr, |
| EndpointIdType | endpoint_ = EndpointIdType() ) |
Construct an Invalid Message using the conn and endpoint_.
| Message | ( | Message::MessageType | type_, |
| Connection * | conn = nullptr, | ||
| EndpointIdType | endpoint_ = EndpointIdType() ) |
Construct an empty Message with the specified type that uses the conn and endpoint_.
| Message | ( | const QJsonObject & | rawJson, |
| Connection * | conn = nullptr, | ||
| EndpointIdType | endpoint_ = EndpointIdType() ) |
| Message | ( | const Message & | other | ) |
Copy constructor.
| Message::MessageType type | ( | ) | const |
| QString method | ( | ) | const |
The name of the method used in the remote procedure call.
| QJsonValue params | ( | ) | const |
The parameters used in the remote procedure call.
| QJsonValue result | ( | ) | const |
The result object used in a remote procedure call response.
| int errorCode | ( | ) | const |
The integral error code used in a remote procedure call error response.
| QString errorMessage | ( | ) | const |
The error message string used in a remote procedure call error response.
| QJsonValue errorData | ( | ) | const |
The data object used in a remote procedure call error response.
| MessageIdType id | ( | ) | const |
The message id used in a remote procedure call.
| Connection * connection | ( | ) | const |
The connection associated with the remote procedure call.
| EndpointIdType endpoint | ( | ) | const |
The connection endpoint associated with the remote procedure call.
| QJsonObject toJsonObject | ( | ) | const |
| PacketType toJson | ( | ) | const |
| bool send | ( | ) |
Send the message to the associated connection and endpoint.
| Message generateResponse | ( | ) | const |
Create a new Response message in reply to a Request. The connection, endpoint, id, and method will be copied from this Message.
| Message generateErrorResponse | ( | ) | const |
Create a new Error message in reply to a Request. The connection, endpoint, id, and method will be copied from this Message.
| bool parse | ( | ) |
Interpret the raw QJsonObject passed to the constructor.