Page tree
Skip to end of metadata
Go to start of metadata

Simple Streams

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:

Browser Streams

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.

Own StreamCompletedEvent-Handler (header)
bool onStreamCompleted (FB::StreamCompletedEvent *evt, FB::BrowserStream *Stream);
Own StreamCompletedEvent-Handler (body)
bool MyStreamHandler::onStreamCompleted (FB::StreamCompletedEvent *evt, FB::BrowserStream *Stream)
    m_progress = 100;
    return true;

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.

Registering stream events
    EVENTTYPE_CASE(FB::StreamCompletedEvent, onStreamCompleted, FB::BrowserStream)
    EVENTTYPE_CASE(FB::StreamCreatedEvent, onStreamCreated, FB::BrowserStream)

To download a stream opened by FireBreath into a file you need to overwrite the onStreamDataArrived-event:

Saving arriving data into a file
bool MyStreamHandler::onStreamDataArrived (FB::StreamDataArrivedEvent *evt, FB::BrowserStream *Stream)
    m_progress = (int) evt->getProgress();
    AppendFile((const char*)evt->getData(), evt->getLength());
    return true;

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.

  • No labels


  1. Unknown User (dave)

    error C2039: 'DefaultBrowserStreamHandler' : is not a member of 'FB'

    Have you changed anything?

    1. You probably just need the include of the same name as the class.

  2. Unknown User (dave)

    Thank you Richard!

    #include"defaultbrowserstreamhandler.h"That works. Please include this information in this help when you have a chance.

    PS: FB is awsome!

    1. You're welcome, Dave!  However, might I suggest that you update the docs yourself? This is a wiki.. there is an edit button at the top of the page...

      I try to spend my time fixing bugs and adding features rather than updating all the docs and ask that those who use the framework give back a little bit by helping to keep documentation up to date. I do of course monitor all changes on the wiki and fix any inaccuracies that may slip in.

  3. Unknown User (marselan)

    Is FB::SimpleStreamHelper::AsyncGet thread safe? And how does it handle the connections? It spawns a new thread for each request or it handles all request in a single thread?

    The same question for DefaultBrowserStream 




    1. Yes, AsyncGet and AsyncPost are threadsafe; no, they don't spawn new threads, they are actually asynchronous calls through the browser which will call your plugin back on the main thread.