Skip to content

Commit

Permalink
if desktop client sent a first reply: wait for the menu data
Browse files Browse the repository at this point in the history
may need the user to wait a bit longer but should prevent missing the
context menu

should still be robust since we only wait indefinitely if desktop client
sent a first reply

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Mar 19, 2024
1 parent 7262696 commit ca90ed7
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ NCClientInterface::ContextMenuInfo NCClientInterface::FetchInfo(const std::wstri
ContextMenuInfo info;
std::wstring response;
int sleptCount = 0;
while (sleptCount < 20) {
bool receivedReplayFromDesktopClient = false;
while (receivedReplayFromDesktopClient || sleptCount < 20) {
if (socket.ReadLine(&response)) {
if (StringUtil::begins_with(response, wstring(L"REGISTER_PATH:"))) {
wstring responsePath = response.substr(14); // length of REGISTER_PATH
Expand All @@ -65,6 +66,9 @@ NCClientInterface::ContextMenuInfo NCClientInterface::FetchInfo(const std::wstri
if (!StringUtil::extractChunks(response, commandName, flags, title))
continue;
info.menuItems.push_back({ commandName, flags, title });
} else if (StringUtil::begins_with(response, wstring(L"GET_MENU_ITEMS:BEGIN"))) {
receivedReplayFromDesktopClient = true;
break; // Stop once we completely received the last sent request
} else if (StringUtil::begins_with(response, wstring(L"GET_MENU_ITEMS:END"))) {
break; // Stop once we completely received the last sent request
}
Expand Down

0 comments on commit ca90ed7

Please sign in to comment.