Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/network/scripting/JSInterface_Network.cpp
Show All 27 Lines | |||||
#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/StructuredClone.h" | #include "scriptinterface/StructuredClone.h" | ||||
#include "scriptinterface/JSON.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 226 Lines • ▼ Show 20 Lines | |||||
void StartNetworkGame(const ScriptInterface& scriptInterface, JS::HandleValue attribs1) | void StartNetworkGame(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); | ||||
JS::RootedValue attribs(rq.cx, attribs1); | JS::RootedValue attribs(rq.cx, attribs1); | ||||
g_NetClient->SendStartGameMessage(scriptInterface.StringifyJSON(&attribs)); | g_NetClient->SendStartGameMessage(Script::StringifyJSON(rq, &attribs)); | ||||
} | } | ||||
void SetTurnLength(int length) | void SetTurnLength(int length) | ||||
{ | { | ||||
if (g_NetServer) | if (g_NetServer) | ||||
g_NetServer->SetTurnLength(length); | g_NetServer->SetTurnLength(length); | ||||
else | else | ||||
LOGERROR("Only network host can change turn length"); | LOGERROR("Only network host can change turn length"); | ||||
Show All 24 Lines |
Wildfire Games · Phabricator