当前位置: 首页>>代码示例>>C++>>正文


C++ IOBuffer::getNumBytesStored方法代码示例

本文整理汇总了C++中IOBuffer::getNumBytesStored方法的典型用法代码示例。如果您正苦于以下问题:C++ IOBuffer::getNumBytesStored方法的具体用法?C++ IOBuffer::getNumBytesStored怎么用?C++ IOBuffer::getNumBytesStored使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IOBuffer的用法示例。


在下文中一共展示了IOBuffer::getNumBytesStored方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: parseHTTPRequest

bool ofxAMFHTTPRequest::parseHTTPRequest(IOBuffer& buffer, IOBuffer& amfResultBuffer) {
	// step 1. parse http headers
	if(num_bytes_in_header == 0) {
		num_bytes_in_header = buffer.consumeUntil("\r\n\r\n", raw_headers);
	}
	
	// step 2. parse headers when all received.
	if(num_bytes_in_header != 0) {
		if(parseHTTPHeaders()) {
			num_bytes_in_body = headers["content-length"].getAsUInt32();
		}
	}
	else {
		return false;
	}
	
	// step 3. parse body when received content-length.
	if(num_bytes_in_body != 0) {
		uint32_t bytes_stored = buffer.getNumBytesStored();
		uint32_t bytes_total = num_bytes_in_header + num_bytes_in_body;
		uint32_t bytes_left = bytes_total - bytes_stored;
		if(bytes_left == 0) {
			amfResultBuffer.storeBuffer(buffer, num_bytes_in_body);
			//cout << headers.toString() << endl;
			return true;
		}
	}
	return false;
}
开发者ID:deathmemory,项目名称:ofxFlashCommunication,代码行数:29,代码来源:ofxAMFHTTPRequest.cpp

示例2: createHTTPResponse

// prepends the headers to the buffer for a http resonse.
IOBuffer ofxAMFHTTPResponse::createHTTPResponse(IOBuffer& buffer) {
	IOBuffer http_buffer;
	http_buffer.setup(buffer.getNumBytesStored());
	http_buffer.storeString("HTTP/1.1 200 OK\r\n");

	stringstream ss;
	ss << "Content-Length: " << buffer.getNumBytesStored() << "\r\n";
	http_buffer.storeString(ss.str());
	
	http_buffer.storeString("Connection: close\r\n");
	http_buffer.storeString("Content-type: application/x-amf\r\n");
	http_buffer.storeString("\r\n");
	
	http_buffer.storeBuffer(buffer);
	return http_buffer;

	
}
开发者ID:deathmemory,项目名称:ofxFlashCommunication,代码行数:19,代码来源:ofxAMFHTTPResponse.cpp

示例3: storeBuffer

// copy data from another buffer.
void IOBuffer::storeBuffer(IOBuffer& other) {
	storeBuffer(other, other.getNumBytesStored());	
}
开发者ID:basseyndon,项目名称:roxlu_experimental,代码行数:4,代码来源:IOBuffer.cpp


注:本文中的IOBuffer::getNumBytesStored方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。