Esempio n. 1
0
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;
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
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);
}
Esempio n. 6
0
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;
}