SensESP 3.0.1
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 (JsonDocument &request, std::function< void(JsonDocument &)> callback, uint32_t timeout=5000)
 
static void handle_response (JsonDocument &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 19 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 49 of file signalk_put_request.cpp.

Here is the caller graph for this function:

◆ handle_response()

void sensesp::SKRequest::handle_response ( JsonDocument & response)
static

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

Definition at line 57 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 events if necessary

Definition at line 75 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 ( JsonDocument & request,
std::function< void(JsonDocument &)> 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 10 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 55 of file signalk_put_request.h.


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