コード例 #1
0
ファイル: GProtoSocket.cpp プロジェクト: furen2013/testwork
void CGProtoSocket::on_connect()
{
	MyLog::log->info( "%s is connected remote address : %s",serverName.c_str(), get_remote_address_string().c_str());

	if (firstconnect = true)
	{
		firstconnect = false;
	}
	tcp_ProtoClient::on_connect();

	m_isreconnect = true;
}
コード例 #2
0
ファイル: game_client.cpp プロジェクト: kingstop/crashmo
void GateGameClient::on_connect()
{
    tcp_client::on_connect();
    Mylog::log_server(LOG_INFO, "connect game server [%s]  id [%u] success!" , get_remote_address_string().c_str() ,m_GameInfo.game_id );
	service_config conf = gGateServer.getServiceConf();
	message::MsgServerRegister msg;
	msg.set_serverid(conf.id);
	message::ServerVersion* p2 = msg.mutable_version();
	p2->set_major(gGTVersion.nMajor);
	p2->set_minor(gGTVersion.nMinor);
	p2->set_build(gGTVersion.nBuild);
	p2->set_appsvn(gGTVersion.nAppSvn);
	sendPBMessage(&msg);
}
コード例 #3
0
void tcp_basesession::on_accept( tcp_server* p )
{
	p->increase_connection_count();
	m_isconnected = true;
	m_last_action_time = (unsigned int)time( NULL );
	m_father = p;
	m_dsv.reset();
	_accept();
	//m_send_crypt_key = rand() % 255 + 1;
	//m_recv_crypt_key = m_send_crypt_key;
	//send_message( &m_send_crypt_key, 1 );
	_read_next_message();
	m_thread_index = p->generate_thread_index();

	m_remote_ip_str = get_remote_address_string();
	m_remote_ip_ui = get_remote_address_ui();
	_record_action();
}
コード例 #4
0
void tcp_basesession::handle_read_header( const boost::system::error_code& error )
{
	if( !is_valid() )
		return;

	if( !error )
	{
		_record_action();

		unsigned short datalen = *(unsigned short*)m_recv_buffer;
		m_recv_size += datalen;

		if( datalen > m_message_head_len )
		{
			//assert( datalen <= MAX_MESSAGE_LEN );
			_async_read(datalen);
			//boost::asio::async_read( *m_socket,
			//	boost::asio::buffer( m_recv_buffer + m_message_head_len, datalen - m_message_head_len ),
			//	boost::bind( &tcp_basesession::handle_read_body, this,
			//	boost::asio::placeholders::error ) );
		}
		else if( datalen == m_message_head_len )
		{
			_Read_Other();
		}
		else
		{
			//printf( "datalen < 12, close socket\n" );
			if( m_father )
			{
				m_father->add_ban_ip( this->get_remote_address_ui(), 120, net_global::BAN_REASON_HACK_PACKET );
				printf( "IP:[%s] try to hack server. Ban it for 120 seconds.\n", get_remote_address_string().c_str() );
			}
			this->close();
			net_global::write_close_log( "IP:[%s] message length is not valid", this->get_remote_address_string().c_str() );
		}
	}
	else
		_on_close( error );
}
コード例 #5
0
ファイル: db_client .cpp プロジェクト: kingstop/crashmo
void GameDBClient::on_connect_failed( boost::system::error_code error )
{
	 Mylog::log_server(LOG_ERROR, "connect DBServer ip:[%s] failed!", get_remote_address_string().c_str());
}