Simple Streams is a feature new in FireBreath 1.4 (as of beta 3) for making quite HTTP GET requests. This is ideal for those who just want to download text documents or use web services.
Simple Streams calls are static calls off of the FB::SimpleStreamHelper class. There are currently two supported:
- FB::SimpleStreamHelper::AsyncGet - Can be called from any thread, calls the supplied function on the main thread when the download completes.
- FB::SimpleStreamHelper::SynchronousGet - May be called from any thread except the main thread; makes an asynchronous call, waits for it to complete, and returns.
Firebreath offers browser streams to handle downloads.
You can derive a subclass from
FB::DefaultBrowserStreamHandler to create your own download handler.
The base class offers the required event handling for such as stream created or data incoming.
To react to those events you would overwrite the "onStream"-methods, e. g.
All of these events need to be registered in the Header file as follows. Note that you do not need to register the methods if you derive from DefaultBrowserStream as the registration is done in the base class. In that case you simply overwrite the methods in your subclass.
To download a stream opened by FireBreath into a file you need to overwrite the onStreamDataArrived-event:
This event is emitted when some amount of data arrived from the stream. Just use the evt-pointer as shown to get the data and progress.
Now you can start adding your own functionality like handling files and updating progress.