Пример #1
0
void TCP_Handler::handle_connection(tcp_session_ptr tcp_session, const boost::system::error_code& error){
    
    if(!error){
        tcp_session->start();
    }
    
    accept_connection();
    
}
Пример #2
0
  void handle_accept(tcp_session_ptr session,
      const asio::error_code& ec)
  {
    if (!ec)
    {
      session->start();
    }

    start_accept();
  }
Пример #3
0
  void handle_accept(tcp_session_ptr session,
      const boost::system::error_code& ec)
  {
    if (!ec)
    {
      session->start();

      tcp_session_ptr new_session(new tcp_session(io_service_, channel_));

      acceptor_.async_accept(new_session->socket(),
          boost::bind(&server::handle_accept, this, new_session, _1));
    }
  }
Пример #4
0
		void msg_server::handle_accept(tcp_session_ptr new_connection,acceptor_pointer ap,const boost::system::error_code& error)
		{
			
			if(_is_stop) return;
			if (!error)
			{
				_map_client[new_connection->get_net_id()] = new_connection;				
				//LogT<<  "new gate server[" << new_connection->get_net_id() << "] connected ..." << LogEnd;
				new_connection->start(new_connection->get_net_id(),shared_from_this());
				on_connect(new_connection->get_net_id(),new_connection);
				
				start_accept(ap);
			}
		}
Пример #5
0
	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();								
			//}
			
		}
	}