SensESP 2.7.2
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
sensesp::SKRequest Class Reference

A base class for all objects that are capable of sending "requests" to the SignalK server (and optionally receiving the responses) according to the specification located at https://signalk.org/specification/1.5.0/doc/request_response.html. More...

#include <sensesp/signalk/signalk_put_request.h>

Inheritance diagram for sensesp::SKRequest:
[legend]

Classes

class  PendingRequest
 

Static Public Member Functions

static String send_request (DynamicJsonDocument &request, std::function< void(DynamicJsonDocument &)> callback, uint32_t timeout=5000)
 
static void handle_response (DynamicJsonDocument &response)
 

Static Protected Member Functions

static void remove_request (String request_id)
 
static PendingRequestget_request (String request_id)
 

Static Protected Attributes

static std::map< String, PendingRequest * > request_map
 

Detailed Description

A base class for all objects that are capable of sending "requests" to the SignalK server (and optionally receiving the responses) according to the specification located at https://signalk.org/specification/1.5.0/doc/request_response.html.

Definition at line 20 of file signalk_put_request.h.

Member Function Documentation

◆ get_request()

SKRequest::PendingRequest * sensesp::SKRequest::get_request ( String  request_id)
staticprotected

Returns the pending request object associated with request_id, or nullptr if no such id is found.

Definition at line 50 of file signalk_put_request.cpp.

Here is the caller graph for this function:

◆ handle_response()

void sensesp::SKRequest::handle_response ( DynamicJsonDocument response)
static

Is called by the web socket code to handle any incoming request responses that is receives.

Definition at line 59 of file signalk_put_request.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_request()

void sensesp::SKRequest::remove_request ( String  request_id)
staticprotected

Removes the specified request_id from the request_map, cleaning up outstanding reactions if necessary

Definition at line 76 of file signalk_put_request.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_request()

String sensesp::SKRequest::send_request ( DynamicJsonDocument request,
std::function< void(DynamicJsonDocument &)>  callback,
uint32_t  timeout = 5000 
)
static

Sends the specified request to the server via the connected websocket.

Parameters
requestThe json document to send for the request. This document should follow the formats specified in the SignalK Request/Response specification with the exception that it should not contain a "requestId" (as this method will add it).
callbackThe callback method that processes any and all responses from the server that correspond to the request.
timeoutThe number of milliseconds to wait for a COMPLETED or FAILED response to be received from the server
Returns
The request Id that is sent to the server.

Definition at line 12 of file signalk_put_request.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ request_map

std::map< String, SKRequest::PendingRequest * > sensesp::SKRequest::request_map
staticprotected

A map to hold all of the requests we are expecting future responses from...

Definition at line 56 of file signalk_put_request.h.


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