Handle for ASYNC_STREAM calls Provides onData() for intermediate updates, plus then()/catch_() for final result
| 21 | /// Handle for ASYNC_STREAM calls |
| 22 | /// Provides onData() for intermediate updates, plus then()/catch_() for final result |
| 23 | class StreamHandle { |
| 24 | public: |
| 25 | StreamHandle() FL_NOEXCEPT = default; |
| 26 | |
| 27 | /// Register callback for intermediate stream data |
| 28 | StreamHandle& onData(fl::function<void(const fl::json&)> cb); |
| 29 | |
| 30 | /// Register callback for final result |
| 31 | StreamHandle& then(fl::function<void(const fl::json&)> cb); |
| 32 | |
| 33 | /// Register callback for errors |
| 34 | StreamHandle& catch_(fl::function<void(const fl::task::Error&)> cb); |
| 35 | |
| 36 | /// Access the underlying promise |
| 37 | fl::task::Promise<fl::json>& promise(); |
| 38 | |
| 39 | /// Check if handle is valid |
| 40 | bool valid() const; |
| 41 | |
| 42 | private: |
| 43 | friend class HttpStreamTransport; |
| 44 | StreamHandle(fl::task::Promise<fl::json> p, |
| 45 | fl::shared_ptr<fl::function<void(const fl::json&)>> updateCb); |
| 46 | |
| 47 | fl::task::Promise<fl::json> mPromise; |
| 48 | fl::shared_ptr<fl::function<void(const fl::json&)>> mUpdateCallback; |
| 49 | }; |
| 50 | |
| 51 | /// Base class for HTTP streaming transport |
| 52 | /// Implements RequestSource and ResponseSink for Remote class |