Skip to content

Commit

Permalink
Minor fix before release
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyfreg committed Dec 8, 2024
1 parent de61ed1 commit a92f5ba
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 9 additions & 1 deletion Code/Client/Private/NetImgui_Api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ bool NewFrame(bool bSupportFrameSkip)

// Update input and see if remote netImgui expect a new frame
client.mSavedDisplaySize = ImGui::GetIO().DisplaySize;
client.mbValidDrawFrame = client.mDesiredFps > 0.f && (elapsedDrawMs + elapsedCheckMs/2.f) > (1000.f/client.mDesiredFps); // Take into account delay until next method call, for more precise fps
client.mbValidDrawFrame = false;

// Take into account delay until next method call, for more precise fps
if( client.mDesiredFps > 0.f && (elapsedDrawMs + elapsedCheckMs/2.f) > (1000.f/client.mDesiredFps) )
{
client.mLastOutgoingDrawTime = std::chrono::steady_clock::now();
client.mbValidDrawFrame = true;
}

ProcessInputData(client);

// We are about to start drawing for remote context, check for font data update
Expand Down
3 changes: 1 addition & 2 deletions Code/Client/Private/NetImgui_Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ bool Communications_Initialize(ClientInfo& client)
PendingRcv.pCommand = reinterpret_cast<CmdPendingRead*>(&cmdVersionRcv);
while( !PendingRcv.IsDone() && cmdVersionRcv.mType == CmdHeader::eCommands::Version )
{
while( !Network::DataReceivePending(client.mpSocketPending) ){
while( !client.mbDisconnectPending && !Network::DataReceivePending(client.mpSocketPending) ){
std::this_thread::yield(); // Idle until we receive the remote data
}
Network::DataReceive(client.mpSocketPending, PendingRcv);
Expand Down Expand Up @@ -701,7 +701,6 @@ void ClientInfo::ProcessDrawData(const ImDrawData* pDearImguiData, ImGuiMouseCur

CmdDrawFrame* pDrawFrameNew = ConvertToCmdDrawFrame(pDearImguiData, mouseCursor);
pDrawFrameNew->mCompressed = mClientCompressionMode == eCompressionMode::kForceEnable || (mClientCompressionMode == eCompressionMode::kUseServerSetting && mServerCompressionEnabled);
mLastOutgoingDrawTime = std::chrono::steady_clock::now();
mPendingFrameOut.Assign(pDrawFrameNew);
}

Expand Down
12 changes: 6 additions & 6 deletions Code/ServerApp/Source/NetImguiServer_Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ bool Communications_InitializeClient(NetImgui::Internal::Network::SocketInfo* pC
cmdVersionSend.mFlags |= ConnectExclusive ? static_cast<uint8_t>(NetImgui::Internal::CmdVersion::eFlags::ConnectExclusive) : 0;
cmdVersionSend.mFlags |= ConnectForce ? static_cast<uint8_t>(NetImgui::Internal::CmdVersion::eFlags::ConnectForce) : 0;
PendingSend.pCommand = reinterpret_cast<CmdPendingRead*>(&cmdVersionSend);
while( !PendingSend.IsDone() ){
while( !gbShutdown && !PendingSend.IsDone() ){
::Network::DataSend(pClientSocket, PendingSend);
}

Expand All @@ -253,13 +253,13 @@ bool Communications_InitializeClient(NetImgui::Internal::Network::SocketInfo* pC
PendingRcv.pCommand = reinterpret_cast<CmdPendingRead*>(&cmdVersionRcv);
while( !PendingRcv.IsDone() && cmdVersionRcv.mType == CmdHeader::eCommands::Version )
{
while( !::Network::DataReceivePending(pClientSocket) ){
while( !gbShutdown && !::Network::DataReceivePending(pClientSocket) ){
std::this_thread::yield(); // Idle until we receive the remote data
}
::Network::DataReceive(pClientSocket, PendingRcv);
}

if( !PendingRcv.IsError() )
if( !gbShutdown && !PendingRcv.IsError() )
{
//---------------------------------------------------------------------
// Connection accepted, initialize client
Expand Down Expand Up @@ -450,8 +450,7 @@ void NetworkConnectRequest_Send()
bool Startup( )
{
// Relying on shared network implementation for Winsock Init
if( !NetImgui::Internal::Network::Startup() )
{
if( !NetImgui::Internal::Network::Startup() ){
return false;
}

Expand All @@ -470,8 +469,9 @@ void Shutdown()
gbShutdown = true;
NetImgui::Internal::Network::SocketInfo* socketDisconnect = gListenSocket.exchange(nullptr);
NetImgui::Internal::Network::Disconnect(socketDisconnect);
while( gActiveClientThreadCount > 0 || gActiveThreadConnectIn || gActiveThreadConnectOut )
while( gActiveClientThreadCount > 0 || gActiveThreadConnectIn || gActiveThreadConnectOut ){
std::this_thread::yield();
}

NetImgui::Internal::Network::Shutdown();
}
Expand Down

0 comments on commit a92f5ba

Please sign in to comment.