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


C++ Block_Buffer::readable_bytes方法代码示例

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


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

示例1: process_block

int Login_Client_Messager::process_block(Block_Buffer &buf) {
	LOGIN_MANAGER->add_recv_bytes(buf.readable_bytes());

	int32_t cid = 0;
	int16_t len = 0;
	int32_t msg_id = 0;
	int32_t status = 0;
	int32_t serial_cipher = 0;
	int32_t msg_time_cipher = 0;
	buf.read_int32(cid);
	buf.read_int16(len);
	buf.read_int32(msg_id);
	buf.read_int32(status);
	buf.read_int32(serial_cipher);
	buf.read_int32(msg_time_cipher);

	LOGIN_MANAGER->add_msg_count(msg_id);
	switch (msg_id) {
	case REQ_CONNECT_LOGIN:{
			connect_login(cid, msg_id, buf);
			break;
	}
	default:	{
		LOG_ERROR("error msg_id:%d", msg_id);
		break;
	}
	}

	return 0;
}
开发者ID:jice1001,项目名称:server,代码行数:30,代码来源:Login_Client_Messager.cpp

示例2: send_to_gate

int Game_Manager::send_to_gate(int gate_cid, Block_Buffer &buf) {
	if (gate_cid < 2) {
		LOG_ERROR("gate_cid = %d", gate_cid);
		return -1;
	}
	add_send_bytes(buf.readable_bytes());
	return GAME_GATE_SERVER->send_block(gate_cid, buf);
}
开发者ID:jice1001,项目名称:server,代码行数:8,代码来源:Game_Manager.cpp

示例3: send_to_master

int Game_Manager::send_to_master(Block_Buffer &buf) {
	int master_cid = GAME_MASTER_CONNECTOR->get_cid();
	if (master_cid < 2) {
		LOG_ERROR("master_cid = %d", master_cid);
		return -1;
	}
	add_send_bytes(buf.readable_bytes());
	return GAME_MASTER_CONNECTOR->send_block(master_cid, buf);
}
开发者ID:jice1001,项目名称:server,代码行数:9,代码来源:Game_Manager.cpp

示例4: send_to_log

int Game_Manager::send_to_log(Block_Buffer &buf) {
	int log_cid = LOG_CONNECTOR->get_cid();
	if (log_cid < 2) {
		LOG_ERROR("db_cid = %d", log_cid);
		return -1;
	}
	add_send_bytes(buf.readable_bytes());
	return LOG_CONNECTOR->send_block(log_cid, buf);
}
开发者ID:jice1001,项目名称:server,代码行数:9,代码来源:Game_Manager.cpp

示例5: send_to_db

int Game_Manager::send_to_db(Block_Buffer &buf) {
	int db_cid = GAME_DB_CONNECTOR->get_cid();
	if (db_cid < 2) {
		LOG_ERROR("db_cid = %d", db_cid);
		return -1;
	}
	add_send_bytes(buf.readable_bytes());
	return GAME_DB_CONNECTOR->send_block(db_cid, buf);
}
开发者ID:jice1001,项目名称:server,代码行数:9,代码来源:Game_Manager.cpp

示例6: process_block

int Gate_Client_Messager::process_block(Block_Buffer &buf) {
	GATE_MANAGER->add_recv_bytes(buf.readable_bytes());

	int32_t cid = 0;
	int16_t len = 0;
	int32_t msg_id = 0;
	int32_t status = 0;
	int32_t serial_cipher = 0;
	int32_t msg_time_cipher = 0;
	buf.read_int32(cid);
	buf.read_int16(len);
	buf.read_int32(msg_id);
	buf.read_int32(status);
	buf.read_int32(serial_cipher);
	buf.read_int32(msg_time_cipher);

	GATE_MANAGER->add_msg_count(msg_id);
	if (msg_id >= CLIENT_GATE_MESSAGE_START && msg_id <= CLIENT_GATE_MESSAGE_END) {
		return process_gate_block(cid, msg_id, buf);
	}

	Gate_Player *player = dynamic_cast<Gate_Player*>(GATE_MANAGER->find_cid_player(cid));
	if (!player) {
		LOG_ERROR("cannot find player_cid = %d msg_id = %d ", cid, msg_id);
		return GATE_MANAGER->close_client(0, cid, ERROR_NOT_LOGIN);
	}

	 /// 校验包, 用于防截包/自组包/重复发包
	if (GATE_MANAGER->verify_pack()) {
		int result = player->verify_msg_info(serial_cipher, msg_time_cipher);
		if (result != 0) {
			LOG_ERROR("msg verify error, player_cid:%d, len:%d, serial_cipher:%d, msg_time_cipher:%d, msg_id:%d, status:%d", cid, len, serial_cipher, msg_time_cipher, msg_id, status);
			return GATE_MANAGER->close_client(0, cid, result);
		}
	}

	Block_Buffer player_buf;
	player_buf.reset();
	player_buf.make_player_message(msg_id, status, cid);
	player_buf.copy(&buf);
	player_buf.finish_message();

	if (msg_id >= CLIENT_MASTER_MESSAGE_START && msg_id <= CLIENT_MASTER_MESSAGE_END) {
		GATE_MANAGER->send_to_master(player_buf);
	} else if (msg_id >= CLIENT_GAME_MESSAGE_START && msg_id <= CLIENT_GAME_MESSAGE_END) {
		GATE_MANAGER->send_to_game(player->game_cid(), player_buf);
	}
	else {
		LOG_ERROR("msg_id:%d error", msg_id);
	}

	return 0;
}
开发者ID:jice1001,项目名称:server,代码行数:53,代码来源:Gate_Client_Messager.cpp


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