本文整理汇总了C++中boost::scoped_ptr::readNonBlocking方法的典型用法代码示例。如果您正苦于以下问题:C++ scoped_ptr::readNonBlocking方法的具体用法?C++ scoped_ptr::readNonBlocking怎么用?C++ scoped_ptr::readNonBlocking使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::scoped_ptr
的用法示例。
在下文中一共展示了scoped_ptr::readNonBlocking方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
HTTPRemotingHandler::advance()
{
#ifdef GNASH_DEBUG_REMOTING
log_debug("advancing HTTPRemotingHandler");
#endif
if (_connection) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("have connection");
#endif
// Fill last chunk before reading in the next
size_t toRead = reply.capacity() - reply.size();
if (! toRead) toRead = NCCALLREPLYCHUNK;
#ifdef GNASH_DEBUG_REMOTING
log_debug("Attempt to read %d bytes", toRead);
#endif
// See if we need to allocate more bytes for the next
// read chunk
if (reply.capacity() < reply.size() + toRead) {
// if _connection->size() >= 0, reserve for it, so
// if HTTP Content-Length response header is correct
// we'll be allocating only once for all.
const size_t newCapacity = reply.size() + toRead;
#ifdef GNASH_DEBUG_REMOTING
log_debug("NetConnection.call: reply buffer capacity (%d) "
"is too small to accept next %d bytes of chunk "
"(current size is %d). Reserving %d bytes.",
reply.capacity(), toRead, reply.size(), newCapacity);
#endif
reply.reserve(newCapacity);
#ifdef GNASH_DEBUG_REMOTING
log_debug(" after reserve, new capacity is %d", reply.capacity());
#endif
}
const int read =
_connection->readNonBlocking(reply.data() + reply.size(), toRead);
if (read > 0) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("read '%1%' bytes: %2%", read,
hexify(reply.data() + reply.size(), read, false));
#endif
reply.resize(reply.size() + read);
}
// There is no way to tell if we have a whole amf reply without
// parsing everything
//
// The reply format has a header field which specifies the
// number of bytes in the reply, but potlatch sends 0xffffffff
// and works fine in the proprietary player
//
// For now we just wait until we have the full reply.
//
// FIXME make this parse on other conditions, including: 1) when
// the buffer is full, 2) when we have a "length in bytes" value
// thas is satisfied
if (_connection->bad()) {
log_debug("connection is in error condition, calling "
"NetConnection.onStatus");
reply.resize(0);
reply_start = 0;
// reset connection before calling the callback
_connection.reset();
// This is just a guess, but is better than sending
// 'undefined'
_nc.notifyStatus(NetConnection_as::CALL_FAILED);
}
else if (_connection->eof()) {
if (reply.size() > 8) {
#ifdef GNASH_DEBUG_REMOTING
log_debug("hit eof");
#endif
boost::uint16_t li;
const boost::uint8_t *b = reply.data() + reply_start;
const boost::uint8_t *end = reply.data() + reply.size();
amf::Reader rd(b, end, getGlobal(_nc.owner()));
// parse header
b += 2; // skip version indicator and client id
// NOTE: this looks much like parsing of an OBJECT_AMF0
boost::int16_t si = readNetworkShort(b);
b += 2; // number of headers
uint8_t headers_ok = 1;
//.........这里部分代码省略.........