FastLED 3.10.9
Loading...
Searching...
No Matches
response_stream.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/function.h"
4#include "fl/stl/json.h"
6#include "fl/stl/noexcept.h"
7
8namespace fl {
9
13 fl::function<void(fl::JsonStreamWriter&, const fl::json&, const fl::json&)>;
14
16 const fl::json& id) FL_NO_EXCEPT {
17 if (!id.has_value() || id.is_null()) {
18 writer.valueNull();
19 return;
20 }
21 // Echo the id exactly as received, including non-integer numbers.
22 writer.value(id);
23}
24
27 const fl::json& requestId,
28 bool includeId,
29 const fl::JsonStreamCallback& writeResult) FL_NO_EXCEPT {
30 writer.beginObject();
31 writer.member("jsonrpc", "2.0");
32 writer.key("result");
33 if (writeResult) {
34 writeResult(writer);
35 } else {
36 writer.valueNull();
37 }
38 if (includeId) {
39 writer.key("id");
41 }
42 writer.endObject();
43}
44
45} // namespace fl
int requestId
FastLED's Elegant JSON Library: fl::json
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
void streamJsonRpcId(fl::JsonStreamWriter &writer, const fl::json &id) FL_NO_EXCEPT
fl::function< void(fl::JsonStreamWriter &)> JsonStreamCallback
fl::function< void(fl::JsonStreamWriter &, const fl::json &, const fl::json &)> StreamingRpcHandler
void streamJsonRpcResultEnvelope(fl::JsonStreamWriter &writer, const fl::json &requestId, bool includeId, const fl::JsonStreamCallback &writeResult) FL_NO_EXCEPT
fl::function< void(fl::JsonStreamCallback)> ResponseStreamSink
Base definition for an LED controller.