Beispiel #1
0
        void NetworkManagerMaster::Update(double p_dt)
        {
            // When we receive we send
            ReceiveMessages();

            UpdateTimeouts(p_dt);
        }
uint32 FTcpMessageTransportConnection::Run()
{
	while (bRun)
	{
		// Try sending and receiving messages and detect if they fail or if another connection error is reported.
		if ((!ReceiveMessages() || !SendMessages() || Socket->GetConnectionState() == SCS_ConnectionError) && bRun)
		{
			// Disconnected. Reconnect if requested.
			if (ConnectionRetryDelay > 0)
			{
				UE_LOG(LogTcpMessaging, Verbose, TEXT("Connection to '%s' failed, retrying..."), *RemoteEndpoint.ToString());
				FPlatformProcess::Sleep(ConnectionRetryDelay);

				ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(Socket);
				Socket = FTcpSocketBuilder(TEXT("FTcpMessageTransport.RemoteConnection"));
				if (Socket && Socket->Connect(RemoteEndpoint.ToInternetAddr().Get()))
				{
					bSentHeader = false;
					bReceivedHeader = false;
					UpdateConnectionState(STATE_DisconnectReconnectPending);
					RemoteNodeId.Invalidate();
				}
				else
				{
					if (Socket)
					{
						ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(Socket);
						Socket = nullptr;
					}
					bRun = false;
				}
			}
			else
			{
				bRun = false;
			}
		}

		FPlatformProcess::Sleep(0.0f);
	}

	UpdateConnectionState(STATE_Disconnected);
	RemoteNodeId.Invalidate();
	ClosedTime = FDateTime::UtcNow();

	// Clear the delegate to remove a reference to this connection
	ConnectionStateChangedDelegate.Unbind();
	return 0;
}
Beispiel #3
0
void NetworkThread::Run()
{
	while(ReceiveMessages())
	{
		if(myPacket && !myPacket.endOfPacket())
		{
			ParseMessages();
			myPacket.clear();
		}
		
		CheckConnection();
		
		sf::sleep(sf::milliseconds(100));
	}
}
Beispiel #4
0
void ClientSystem::UpdateThread()
{
    while (mRunning)
    {
        //PerfTimer.Log( "client thread update started" );
        if (!mProgramState.mClientConnected)
        {
            //PerfTimer.Log( "client not connected, client update ended" );
            std::this_thread::sleep_for( std::chrono::milliseconds( mWaitMillisecs ) );
            continue;
        }

        ReceiveMessages();

        SendMessages();

        //PerfTimer.Log( "client thread update ended" );
    }
}
Beispiel #5
0
void ClientSystem::Update( double DeltaTime )
{
    PerfTimer.Log( "client update started" );

    if ( !mProgramState.mClientConnected )
    {
        PerfTimer.Log( "client not connected, client update ended" );
        return;
    }

    if (mThreaded)
    {
        std::lock_guard<std::mutex> lck( mMessageHolder.GetOutgoingMessages().GetMutex() );
        mMessageHolder.GetOutgoingMessages().Publish();
        mMessageHolder.GetOutgoingMessages().GetCV().notify_all();
    }
    else
    {
        ReceiveMessages();
        mMessageHolder.GetOutgoingMessages().Publish();
        SendMessages();
    }
    PerfTimer.Log( "client update ended" );
}