Esempio n. 1
0
FCrashUpload::FCrashUpload(const FString& ServerAddress)
	: UrlPrefix(ServerAddress / "CrashReporter")
	, State(EUploadState::NotSet)
	, PauseState(EUploadState::Ready)
{
	SendPingRequest();
}
void CServerContext::Think()
{
	HandleNetworking();

	if(time(0) >= lastping + PING_INTERVAL)
		SendPingRequest();
}
Esempio n. 3
0
int JoinGameLobby::Run(sf::RenderWindow & App)
{
	m_running = true;

	if(!m_Inited)
		Init();

	while(m_running)
	{
		App.Clear();
		App.Draw(m_Background);

		while(App.GetEvent(m_Event))
		{
			if(m_Event.Type == sf::Event::Closed)
			{
				m_running = false;
				return (-1);
			}
			// BACK TO MAIN MENU
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::Escape)
			{
				m_running = false;
				return 1;
			}
			// CHECK PLAYERS ON SERVER
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::F1)
			{
				SendPlayersRequest();
			}
			// JOIN TO GAME
			if(m_Event.Type == sf::Event::KeyPressed && m_Event.Key.Code == sf::Key::F5)
			{
				SendNewPlayerJoin();
			}

			m_serverIPBox->HandleEvent(m_Event);

		} // end of events while loop

#pragma region debuginfo
std::ostringstream bufor;
sf::String tdebug;
tdebug.SetFont(sf::Font::GetDefaultFont());
tdebug.SetSize(20);
tdebug.SetColor(sf::Color(255,0,0,255));
bufor << "Port= " << GMGI->m_SocketUDP.GetPort() << "\nPing= " << m_ServerPing;
bufor << "\n" << "Players Count= " << m_PlayerCount;
tdebug.SetText(bufor.str());
App.Draw(tdebug);	
#pragma endregion

		// if server accept my connection. Go to OnlineGame
		if(m_StartGame)
			return 5;


		RecivePackets();

		// draw textbox for server ip
		m_serverIPBox->Show(App);

		// check ping every 5sec
		if(m_pingclock.GetElapsedTime() >= 5.f)
		{
			SendPingRequest();
			m_pingclock.Reset();
		}

		

		App.Display();
		sf::Sleep(0.01f);
	} // end of while loop

	return (-1);
}