예제 #1
0
파일: login_server.cpp 프로젝트: a1406/fytx
	void login_server::connect(tcp_session_ptr connector, const char* ip_str, const char* port_str )
	{
		if(connector->get_session_status()>gs_null)
			return;
		connector->set_session_status(gs_connecting);
		tcp::resolver resolver(connector->socket().get_io_service());
		tcp::resolver::query query(ip_str, port_str);
		tcp::resolver::iterator iterator = resolver.resolve(query);	

		boost::asio::async_connect(connector->socket(), iterator,
			boost::bind(&login_server::handle_connect,this,connector,
			boost::asio::placeholders::error));
	}
예제 #2
0
파일: login_server.cpp 프로젝트: a1406/fytx
	void login_server::handle_connect(tcp_session_ptr connector,const boost::system::error_code& error)
	{
		if (!error)
		{			
			connector->set_session_status(gs_game);
			connector->socket().non_blocking(true);
			connector->start(connector->get_net_id(),shared_from_this());
			if(connector->get_net_id() == LOG_SVR_NET_ID)
				LogS <<  "mysql server connected ..." << LogEnd;
			//else
			//	LogS <<  "fee server connected ..." << LogEnd;
			//
			//if(connector->get_net_id() == FEE_SVR_NET_ID)
			//{
			//	int server_id = config_ins.get_config_prame("server_id").asInt();
			//	LogS <<  "connecting to fee server ..." << Green << "[" << server_id <<"]" << White << LogEnd;
			//	connector->write((const char*)&server_id,4);
			//}

			//test team battle
			//	Json::Value team;
			//for (int i=0;i<6;++i)
			//	team.append(i+98);
			//	team.append(4539);
			//	team.append(95);

			//Json::Value _mfd_data;
			//_mfd_data["ai"] = Json::arrayValue;

			//for (int i = 0;i<(int)team.size();i++)
			//{
			//	Json::Value temp;
			//	//temp["na"] = "player" + ;
			//	//temp["kid"] = 0;
			//	//temp["lv"] = i;
			//	temp["mw"] = 4;
			//	temp["idm"] = i;
			//	temp["wn"] = 0;
			//	_mfd_data["ai"][0u].append(temp);
			//}

			//battle_system.team_VS(team,1021,_mfd_data);
			//battle_system.send_team_battle_result(1000);
		}
		else
		{
			if(error == boost::asio::error::would_block)
			{
				LogE <<  "************* server is blocking  *********" << LogEnd;
				return;
			}
			//mysql_state = 1;
			connector->set_session_status(gs_null);
			LogE <<  "************* can not connect to server, net_id: " << connector->get_net_id() << " retry ...  *********" << LogEnd;
			//if(connector->get_net_id() == FEE_SVR_NET_ID)
			//{
			//	na::time_helper::sleep(1000000);
			//	connect_to_fee_svr();								
			//}
			
		}
	}