Skip to end of metadata
Go to start of metadata

bool FB::SimpleStreamHelper::onStreamDataArrived ( FB::StreamDataArrivedEvent *  evt,
FB::BrowserStream Stream 
) [virtual]

Called when data arrives.

Author:
Matthias

Reimplemented from FB::DefaultBrowserStreamHandler.

Definition at line 194 of file SimpleStreamHelper.cpp.

00195 {
00196     received += evt->getLength();
00197     const uint8_t* buf = reinterpret_cast<const uint8_t*>(evt->getData());
00198     const uint8_t* endbuf = buf + evt->getLength();
00199 
00200     int len = evt->getLength();
00201     int offset = evt->getDataPosition();
00202     while (buf < endbuf) {
00203         size_t n = offset / blockSize;
00204         size_t pos = offset % blockSize;
00205         if (blocks.size() < n+1) {
00206             blocks.push_back(boost::shared_array<uint8_t>(new uint8_t[blockSize]));
00207         }
00208         uint8_t *destBuf = blocks.back().get();
00209         //if (pos + len > )
00210         int curLen = len;
00211         if (pos + len >= blockSize) {
00212             // If there isn't room in the current block, copy what there is room for
00213             // and loop
00214             curLen = blockSize-pos;
00215         }
00216         // Copy the bytes that fit in this buffer
00217         std::copy(buf, buf+curLen, destBuf+pos);
00218         buf += curLen;
00219         offset += curLen;
00220         len -= curLen;
00221     }
00222     return false;
00223 }


Generated on 25 May 2013 for FireBreath by  doxygen 1.6.1
Labels
  • None