Use promises to fetch net messages

Refs: #5585
This commit is contained in:
phosit
2025-05-07 11:24:39 +02:00
parent 56107e4e39
commit 262c5c037e
13 changed files with 159 additions and 96 deletions
@@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -196,9 +196,12 @@ CStr GetPlayerGUID()
return g_NetClient->GetGUID();
}
JS::Value PollNetworkClient(const ScriptRequest& rq)
JS::Value PollNetworkClient(const ScriptInterface& guiInterface)
{
return g_NetClient ? g_NetClient->GuiPoll(rq) : JS::UndefinedValue();
if (!g_NetClient)
throw std::logic_error{"Network client not present"};
return JS::ObjectValue(*g_NetClient->GetNextGUIMessage(guiInterface));
}
void SendGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue attribs1)