Changeset View
Changeset View
Standalone View
Standalone View
source/network/scripting/JSInterface_Network.cpp
Show All 26 Lines | |||||
#include "network/NetMessage.h" | #include "network/NetMessage.h" | ||||
#include "network/NetServer.h" | #include "network/NetServer.h" | ||||
#include "network/StunClient.h" | #include "network/StunClient.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Game.h" | #include "ps/Game.h" | ||||
#include "ps/GUID.h" | #include "ps/GUID.h" | ||||
#include "ps/Util.h" | #include "ps/Util.h" | ||||
#include "scriptinterface/FunctionWrapper.h" | #include "scriptinterface/FunctionWrapper.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/StructuredClone.h" | ||||
#include "third_party/encryption/pkcs5_pbkdf2.h" | #include "third_party/encryption/pkcs5_pbkdf2.h" | ||||
namespace JSI_Network | namespace JSI_Network | ||||
{ | { | ||||
u16 GetDefaultPort() | u16 GetDefaultPort() | ||||
{ | { | ||||
return PS_DEFAULT_PORT; | return PS_DEFAULT_PORT; | ||||
▲ Show 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | |||||
CStr GetPlayerGUID() | CStr GetPlayerGUID() | ||||
{ | { | ||||
if (!g_NetClient) | if (!g_NetClient) | ||||
return "local"; | return "local"; | ||||
return g_NetClient->GetGUID(); | return g_NetClient->GetGUID(); | ||||
} | } | ||||
JS::Value PollNetworkClient(const ScriptInterface& scriptInterface) | JS::Value PollNetworkClient(const ScriptInterface& guiInterface) | ||||
{ | { | ||||
if (!g_NetClient) | if (!g_NetClient) | ||||
return JS::UndefinedValue(); | return JS::UndefinedValue(); | ||||
// Convert from net client context to GUI script context | // Convert from net client context to GUI script context | ||||
ScriptRequest rqNet(g_NetClient->GetScriptInterface()); | ScriptRequest rqNet(g_NetClient->GetScriptInterface()); | ||||
JS::RootedValue pollNet(rqNet.cx); | JS::RootedValue pollNet(rqNet.cx); | ||||
g_NetClient->GuiPoll(&pollNet); | g_NetClient->GuiPoll(&pollNet); | ||||
return scriptInterface.CloneValueFromOtherCompartment(g_NetClient->GetScriptInterface(), pollNet); | return Script::CloneValueFromOtherCompartment(guiInterface, g_NetClient->GetScriptInterface(), pollNet); | ||||
} | } | ||||
void SendGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue attribs1) | void SendGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue attribs1) | ||||
{ | { | ||||
ENSURE(g_NetClient); | ENSURE(g_NetClient); | ||||
// TODO: This is a workaround because we need to pass a MutableHandle to a JSAPI functions somewhere (with no obvious reason). | // TODO: This is a workaround because we need to pass a MutableHandle to a JSAPI functions somewhere (with no obvious reason). | ||||
ScriptRequest rq(scriptInterface); | ScriptRequest rq(scriptInterface); | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator