Example #1
0
void		CClientDlg::RefillServersList			()
{
	OutputDebugString("CClientDlg::RefillServersList \n");
	ClearHostList();
	// clear the server count
	//	m_serverCount = 0;
	//	m_servers.SetWindowText("0");

	// go through the list of servers
	for(int i = 0; i < ServerBrowserCount(m_serverBrowser) ; i++)
	{
		// if we got basic info for it, put it back in the list
		SBServer server = ServerBrowserGetServer(m_serverBrowser, i);
		//		if(SBServerHasBasicKeys(server))
		AddServerToList(server);//, FALSE);
	}

	UpdateServersList();
};
Example #2
0
void CClientDlg::OnBnClickedRefresh()
{
	ClearHostList();

	m_pBtnJoin.EnableWindow(FALSE);

	if (!Client_Create()) return;
	
	m_pBtnRefresh.EnableWindow(FALSE);

	if (!Client_EnumHosts())
	{
		m_pBtnRefresh.EnableWindow(TRUE);
		Client_Close();
		return;
	};
	Client_Close();
	//-----------------------------------------------------
	m_pBtnRefresh.EnableWindow(TRUE);
	UpdateServersList();
};
Example #3
0
void	CClientDlg::OnFilterChanged			()
{
	CheckFilterButtons();
	UpdateServersList();
};
Example #4
0
int RunDirectoryServer( void* _serverData )
{
	DirectoryServerInfo* serverData = static_cast< DirectoryServerInfo* >( _serverData);

	tcp = RakNet::OP_NEW<RakNet::TCPInterface>(__FILE__,__LINE__);
	httpConnection = RakNet::OP_NEW<RakNet::HTTPConnection>(__FILE__,__LINE__);
	phpDirectoryServer2 = RakNet::OP_NEW<RakNet::PHPDirectoryServer2>(__FILE__,__LINE__);

	tcp->Start(0, 64);
	httpConnection->Init(tcp, LOBBY_SERVER_ADDRESS);
	phpDirectoryServer2->Init(httpConnection, LOBBY_SERVER_PATH_TO_PHP);

	RakNet::RakString httpResult;

	RakNet::TimeMS nextDownload=0;
	RakNet::TimeMS nextUpload=0;
	int serverToUpload=0;
	while( running )
	{
		//NOTE: The http connection can only handle one request at a time.
		//So we priorities upload here.
		if (!myServers.empty() && RakNet::GetTimeMS() > nextUpload)
		{
			//We handle keeping the server alive manually so that it dosent mess with our http downloads.
			//phpDirectoryServer2->UploadTable("a", myServer.get()->name, myServer.get()->address.port, false);
			phpDirectoryServer2->SetField("GUID", myServers[serverToUpload].guid.ToString());
			phpDirectoryServer2->UploadTable("a", myServers[serverToUpload].name.c_str(), myServers[serverToUpload].address.port, false);

			++serverToUpload;
			if (serverToUpload>= (int)myServers.size()) {
				serverToUpload=0;
				nextUpload=RakNet::GetTimeMS()+DIRECTORY_SERVER_UPLOAD_INTERVAL;
			}
			std::cout << "Uploading..." << std::endl;
		} else if(RakNet::GetTimeMS() > nextDownload) {
			nextDownload=RakNet::GetTimeMS()+DIRECTORY_SERVER_DOWNLOAD_INTERVAL;
			phpDirectoryServer2->DownloadTable("a");
			//std::cout << "Downloading..." << std::endl;
		}

		RakNet::Packet *packet = tcp->Receive();
		if(packet)
		{
			httpConnection->ProcessTCPPacket(packet);
			tcp->DeallocatePacket(packet);
		}

		if (httpConnection->HasRead())
		{
			httpResult = httpConnection->Read();
			// Good response, let the PHPDirectoryServer2 class handle the data
			// If resultCode is not an empty string, then we got something other than a table
			// (such as delete row success notification, or the message is for HTTP only and not for this class).
			RakNet::HTTPReadResult readResult = phpDirectoryServer2->ProcessHTTPRead(httpResult);

			if (readResult==RakNet::HTTP_RESULT_GOT_TABLE)
			{
				//printf("RR_READ_TABLE\n");
			}
			else if (readResult==RakNet::HTTP_RESULT_EMPTY)
			{
				//printf("HTTP_RESULT_EMPTY\n");
			}
			UpdateServersList();
		}

		// Update our two classes so they can do time-based updates
		httpConnection->Update();
		phpDirectoryServer2->Update();

		// Don't flood it
		RakSleep(100);
	}

	// The destructor of each of these references the other, so delete in this order
	RakNet::OP_DELETE(phpDirectoryServer2,_FILE_AND_LINE_);
	RakNet::OP_DELETE(httpConnection,_FILE_AND_LINE_);
	RakNet::OP_DELETE(tcp,_FILE_AND_LINE_);

	return 0;
}