BeeeOn Gateway
v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
|
Represents a response to a request message (subclass of a GWRequest). The GWResponse can be used alone as a generic response or inherited by a more specific response object. More...
#include <GWResponse.h>
Public Types | |
enum | Status { ACCEPTED, SUCCESS, FAILED, SUCCESS_PARTIAL } |
typedef Poco::SharedPtr < GWResponse > | Ptr |
Public Types inherited from BeeeOn::GWMessage | |
typedef Poco::SharedPtr < GWMessage > | Ptr |
Public Member Functions | |
GWResponse (const Poco::JSON::Object::Ptr object) | |
void | setStatus (Status status) |
Status | status () const |
void | setAckExpected (bool expected) |
bool | ackExpected () const |
Poco::SharedPtr< GWAck > | ack () const |
Creates and returns a corresponding GWAck message. | |
Public Member Functions inherited from BeeeOn::GWMessage | |
void | setID (const GlobalID &id) |
Set unique identifier intended to match request message with its response. | |
GlobalID | id () const |
Return unique identifier intended to match request message with its response. | |
GWMessageType | type () const |
Returns the type of the message. | |
std::string | toString () const |
Returns the string representation of the message. | |
std::string | toBriefString () const |
Static Public Member Functions | |
static Status | convertStatus (const int value) |
Covert integer value to GWResponse::Status and return it. | |
Static Public Member Functions inherited from BeeeOn::GWMessage | |
static GWMessage::Ptr | fromJSON (const std::string &json) |
Factory method for creating subclasses of the GWMessage from the json string. More... | |
static GWMessage::Ptr | fromJSON (Poco::JSON::Object::Ptr object) |
Factory method for creating subclasses of the GWMessage from the JSON::Object. More... | |
Protected Member Functions | |
GWResponse (const GWMessageTypeEnum::Raw &type) | |
Protected Member Functions inherited from BeeeOn::GWMessage | |
GWMessage (const GWMessageType::Raw &type) | |
Constructs a GWMessage depending on the given type. More... | |
GWMessage (const Poco::JSON::Object::Ptr object) | |
Constructs a GWMessage from the JSON::Object. | |
Poco::JSON::Object::Ptr | json () const |
Represents a response to a request message (subclass of a GWRequest). The GWResponse can be used alone as a generic response or inherited by a more specific response object.
The GWResponse contains unique identifier intended to match a response to a proper request.
The entry "status" is currently represented as integer. It is however possible to use also string representation, any of:
The string representation should be preferred over numbers. The integer representation is treated as obsolete.
Each response can have an optional entry "ack_expected" of type bool. If its value is true then the response is expected to be acknowladged explicitly by a GWAck message. Unless it is acknowladged this way, the client considers such response to be undelivered and may decide to retransmit the response.
An example (generic) response:
{ "id": "b036b7f7-47a1-4bea-9fa3-6024e8263dcd", "message_type": "generic_response", "status": "success" }
An example (generic) response requiring acknowladge:
{ "id": "b036b7f7-47a1-4bea-9fa3-6024e8263dcd", "message_type": "generic_response", "status": "failed", "ack_expected": true }