示例#1
0
int Chat_Player::send_to_client(Block_Buffer &buf, bool use_swap) {
	CHECK_BUFFER_LEN(buf);

	int ret = 0;
	if (buf.is_read_begin()) {
		buf.make_head(0, role_id());
		ret = send_to_gate(buf, use_swap);
		buf.set_read_begin();
	} else {
		Block_Buffer tmp_buf;
		tmp_buf.copy(&buf);
		tmp_buf.make_head(0, role_id());
		ret = send_to_gate(tmp_buf, true);
	}

	return ret;
}
示例#2
0
int Chat_Monitor::send_to_all_gate(Block_Buffer &buf) {
	Block_Buffer tmp_buf;
	tmp_buf.make_message(CHAT_GATE_BROADCAST_BUFF);
	tmp_buf.copy(&buf);
	tmp_buf.finish_message();
	for(Monitor_Mark_Vec::iterator iter = gate_monitor_id_order.begin(); iter != gate_monitor_id_order.end(); ++iter) {
		send_to_gate(*iter, tmp_buf);
	}
	return 0;
}
示例#3
0
int Game_Manager::close_client(int gate_cid, int player_cid, int error_code) {
	if (Server_Manager::close_client(gate_cid, player_cid, error_code) < 0) return -1;

	//将玩家cid投放到js层
	push_drop_player_cid(GET_CID(gate_cid, player_cid));

	if (error_code != 0) {
		//gate与game断开连接不通知客户端,其他情况通知
		Block_Buffer buf;
		buf.make_player_message(ACTIVE_DISCONNECT, error_code, player_cid);
		buf.finish_message();
		send_to_gate(gate_cid, buf);
	}
	return 0;
}