|
FastLED 3.9.15
|
Base class for HTTP streaming transport Implements RequestSource and ResponseSink for Remote class Manages HTTP connection lifecycle with chunked encoding.
Definition at line 54 of file stream_transport.h.
#include <stream_transport.h>
Collaboration diagram for fl::net::http::HttpStreamTransport:Classes | |
| struct | PendingCall |
| struct | PendingStream |
Public Types | |
| using | StateCallback = fl::function<void()> |
| Connection state callback. | |
Public Member Functions | |
| HttpStreamTransport (const fl::string &host, u16 port, u32 heartbeatIntervalMs=30000) | |
| Constructor. | |
| virtual | ~HttpStreamTransport () FL_NOEXCEPT |
| Virtual destructor. | |
| virtual bool | connect ()=0 |
| Connect to server. | |
| virtual void | disconnect ()=0 |
| Disconnect from server. | |
| u32 | getHeartbeatInterval () const |
| Get heartbeat interval. | |
| u32 | getTimeout () const |
| Get connection timeout. | |
| virtual bool | isConnected () const =0 |
| Check if connected. | |
| fl::optional< fl::json > | readRequest () |
| Read next JSON-RPC request from stream Non-blocking, returns nullopt if no complete request available. | |
| fl::task::Promise< fl::json > | rpc (const fl::json &fullRequest) |
| Send a pre-built JSON-RPC request. | |
| fl::task::Promise< fl::json > | rpc (const fl::string &method, const fl::json ¶ms) |
| Send a JSON-RPC request, returns promise that resolves with the final response. | |
| StreamHandle | rpcStream (const fl::json &fullRequest) |
| Send a streaming pre-built JSON-RPC request. | |
| StreamHandle | rpcStream (const fl::string &method, const fl::json ¶ms) |
| Send a streaming JSON-RPC request, returns StreamHandle for intermediate data. | |
| void | setHeartbeatInterval (u32 intervalMs) |
| Set heartbeat interval. | |
| void | setOnConnect (StateCallback callback) |
| Set callback for connection established. | |
| void | setOnDisconnect (StateCallback callback) |
| Set callback for connection lost. | |
| void | setTimeout (u32 timeoutMs) |
| Set connection timeout. | |
| void | update (u32 currentTimeMs) |
| Update connection state (handles reconnection, heartbeat) Call this in main loop. | |
| void | writeResponse (const fl::json &response) |
| Write JSON-RPC response to stream. | |
Protected Member Functions | |
| virtual u32 | getCurrentTimeMs () const |
| Get current time in milliseconds. | |
| virtual int | recvData (fl::span< u8 > buffer)=0 |
| Receive raw data from connection. | |
| virtual int | sendData (fl::span< const u8 > data)=0 |
| Send raw data over connection. | |
| virtual void | triggerReconnect () |
| Trigger reconnection (for subclasses to override) | |
Protected Attributes | |
| HttpConnection | mConnection |
Private Member Functions | |
| void | checkHeartbeatTimeout (u32 currentTimeMs) |
| void | handleConnectionStateChange (u32 currentTimeMs) |
| void | parseChunkedMessages () |
| bool | processIncomingData () |
| bool | resolveRpc (const fl::json &msg, const fl::string &idKey) |
| bool | resolveRpcStream (const fl::json &msg, const fl::string &idKey) |
| void | sendHeartbeat () |
Static Private Member Functions | |
| static fl::string | idToString (const fl::json &id) |
Private Attributes | |
| u32 | mHeartbeatInterval |
| fl::vector< fl::json > | mIncomingQueue |
| u32 | mLastHeartbeatReceived |
| u32 | mLastHeartbeatSent |
| int | mNextCallId = 1 |
| StateCallback | mOnConnect |
| StateCallback | mOnDisconnect |
| fl::flat_map< fl::string, PendingCall, fl::StringFastLess > | mPendingCalls |
| fl::flat_map< fl::string, PendingStream, fl::StringFastLess > | mPendingStreams |
| ChunkedReader | mReader |
| u32 | mTimeoutMs |
| bool | mWasConnected |
| ChunkedWriter | mWriter |