Esempio n. 1
0
//////////////////////////////  1. FileInfo Protocol  //////////////////////////
bool ProtocolFileInfo::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_fileinfo.result;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_fileinfo.fid);
	////file name
	ENCODE_STRING(m_fileinfo.name);
	////file size
	ENCODE_INT(m_fileinfo.size);
	////chunk info
	temp = m_fileinfo.get_chunkpath_count();
	ENCODE_INT(temp);
	while(temp > 0)
	{
		ChunkPath chunkpath = m_fileinfo.get_chunkpath(--temp);
		//chunk id
		ENCODE_STRING(chunkpath.id);
		//chunk ip
		ENCODE_STRING(chunkpath.ip);
		//chunk port
		ENCODE_INT(chunkpath.port);
		//index
		ENCODE_INT(chunkpath.index);
		//chunk offset
		ENCODE_INT(chunkpath.offset);
	}

	return true;
}
Esempio n. 2
0
//////////////////////////////  6. ChunkPing Protocol  //////////////////////////
bool ProtocolChunkPing::encode_body(ByteBuffer *byte_buffer)
{
	////chunk id
	ENCODE_STRING(m_chunk_info.id);
	////chunk ip
	ENCODE_STRING(m_chunk_info.ip);
	////chunk port
	ENCODE_INT(m_chunk_info.port);
	//// disk space
	ENCODE_INT64(m_chunk_info.disk_space);
	////disk used
	ENCODE_INT64(m_chunk_info.disk_used);

	return true;
}
////////////////  请求文件大小  ///////////////////
//编码协议体数据到byte_buffer,成功返回true,失败返回false.
bool RequestSize::encode_body(ByteBuffer *byte_buffer)
{
	int len = 0;
	//file name
	ENCODE_STRING(m_file_name);

	return true;
}
////编码协议体数据到io_buffer,成功返回true,失败返回false.
bool TemplateProtocol::encode_body(ByteBuffer *byte_buffer)
{
	////m_value
	ENCODE_INT(m_value);
	////m_str
	ENCODE_STRING(m_str);

	return true;
}
Esempio n. 5
0
//////////////////////////////  0. FileInfoReq Protocol  //////////////////////////////
bool ProtocolFileInfoReq::encode_body(ByteBuffer *byte_buffer)
{
	////fid
	ENCODE_STRING(m_fid);
	////query chunk path
	char temp = (char)m_query_chunkpath;
	ENCODE_CHAR(temp);

	return true;
}
////////////////  回复文件大小  ////////////////////
//编码协议体数据到byte_buffer,成功返回true,失败返回false.
bool RespondSize::encode_body(ByteBuffer *byte_buffer)
{
	int len = 0;
	//file size
	ENCODE_INT64(m_file_size);
	//file name
	ENCODE_STRING(m_file_name);

	return true;
}
Esempio n. 7
0
//////////////////////////////  7. ChunkPingResp Protocol  //////////////////////////
bool ProtocolChunkPingResp::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_result;
	ENCODE_INT(temp);
	////chunk id
	ENCODE_STRING(m_chunk_id);

	return true;
}
Esempio n. 8
0
//////////////////////////////  2. FileInfoSaveResult Protocol  //////////////////////////
bool ProtocolFileInfoSaveResult::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////result
	temp = (int)m_save_result.result;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_save_result.fid);

	return true;
}
Esempio n. 9
0
//////////////////////////////  4. File Protocol  //////////////////////////
bool ProtocolFile::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	////flag
	temp = (int)m_file_seg.flag;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_file_seg.fid);
	////name
	ENCODE_STRING(m_file_seg.name);
	////file size
	ENCODE_INT(m_file_seg.filesize);
	////seg offset
	ENCODE_INT(m_file_seg.offset);
	////seg index
	ENCODE_INT(m_file_seg.index);
	////seg size
	ENCODE_INT(m_file_seg.size);

	return true;
}
//////////////////////  回复数据  /////////////////////
//编码协议体数据到io_buffer.成功返回编码后协议体长度(大于0),失败返回-1;
bool RespondData::encode_body(ByteBuffer *byte_buffer)
{
	int len = 0;
	//file name
	ENCODE_STRING(m_file_name);
	//start pos
	ENCODE_INT64(m_start_pos);
	//size
	ENCODE_INT(m_size);

	return true;
}
Esempio n. 11
0
//////////////////////////////  5. FileSaveResult Protocol  //////////////////////////
bool ProtocolFileSaveResult::encode_body(ByteBuffer *byte_buffer)
{
	int temp;
	//status
	temp = (int)m_save_result.status;
	ENCODE_INT(temp);
	////fid
	ENCODE_STRING(m_save_result.fid);
	////seg index
	ENCODE_INT(m_save_result.index);

	return true;
}
Esempio n. 12
0
//////////////////////////////  3. FileReq Protocol  //////////////////////////
bool ProtocolFileReq::encode_body(ByteBuffer *byte_buffer)
{
	////fid
	ENCODE_STRING(m_file_req.fid);
	////index
	ENCODE_INT(m_file_req.index);
	////offset
	ENCODE_INT(m_file_req.offset);
	////size
	ENCODE_INT(m_file_req.size);

	return true;
}
Esempio n. 13
0
void RRGLevel::encodeWithEncoder(RRGCoding::Encoder* encoder)
{
    ENCODE_OBJECT(_character1);
    ENCODE_OBJECT(_character2);
    ENCODE_OBJECT(_character3);
    
    ENCODE_VECTOR_OBJECTS(_vectChara);
    ENCODE_MAP_OBJECTS(_mapChara);
    
    ENCODE_INT(_testInt);
    ENCODE_FLOAT(_testFloat);
    ENCODE_STRING(_testString);
    
    ENCODE_ARRAY(_intArray, intArraySize);
    
    ENCODE_VALUEVECTOR(_valueVector);
    ENCODE_VALUEMAP(_valueMap);
    
    ENCODE_VECTOR(_intVector);
    ENCODE_VECTOR(_pointVector);
    
    ENCODE_MAP(_doubleMap);
    ENCODE_MAP(_rectMap);
}