Changeset View
Changeset View
Standalone View
Standalone View
source/network/scripting/JSInterface_Network.cpp
Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | JS::Value PollNetworkClient(const ScriptInterface& scriptInterface) | ||||
// 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 scriptInterface.CloneValueFromOtherCompartment(g_NetClient->GetScriptInterface(), pollNet); | ||||
} | } | ||||
void SetNetworkGameAttributes(const ScriptInterface& scriptInterface, JS::HandleValue attribs1) | void SendGameSetupMessage(const ScriptInterface& scriptInterface, JS::HandleValue message1) | ||||
{ | { | ||||
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 message(rq.cx, message1); | ||||
g_NetClient->SendGameSetupMessage(&attribs, scriptInterface); | g_NetClient->SendGameSetupMessage(&message, scriptInterface); | ||||
} | } | ||||
void AssignNetworkPlayer(int playerID, const CStr& guid) | void AssignNetworkPlayer(int playerID, const CStr& guid) | ||||
{ | { | ||||
ENSURE(g_NetClient); | ENSURE(g_NetClient); | ||||
g_NetClient->SendAssignPlayerMessage(playerID, guid); | g_NetClient->SendAssignPlayerMessage(playerID, guid); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | void RegisterScriptFunctions(const ScriptRequest& rq) | ||||
ScriptFunction::Register<&HasNetServer>(rq, "HasNetServer"); | ScriptFunction::Register<&HasNetServer>(rq, "HasNetServer"); | ||||
ScriptFunction::Register<&HasNetClient>(rq, "HasNetClient"); | ScriptFunction::Register<&HasNetClient>(rq, "HasNetClient"); | ||||
ScriptFunction::Register<&StartNetworkHost>(rq, "StartNetworkHost"); | ScriptFunction::Register<&StartNetworkHost>(rq, "StartNetworkHost"); | ||||
ScriptFunction::Register<&StartNetworkJoin>(rq, "StartNetworkJoin"); | ScriptFunction::Register<&StartNetworkJoin>(rq, "StartNetworkJoin"); | ||||
ScriptFunction::Register<&StartNetworkJoinLobby>(rq, "StartNetworkJoinLobby"); | ScriptFunction::Register<&StartNetworkJoinLobby>(rq, "StartNetworkJoinLobby"); | ||||
ScriptFunction::Register<&DisconnectNetworkGame>(rq, "DisconnectNetworkGame"); | ScriptFunction::Register<&DisconnectNetworkGame>(rq, "DisconnectNetworkGame"); | ||||
ScriptFunction::Register<&GetPlayerGUID>(rq, "GetPlayerGUID"); | ScriptFunction::Register<&GetPlayerGUID>(rq, "GetPlayerGUID"); | ||||
ScriptFunction::Register<&PollNetworkClient>(rq, "PollNetworkClient"); | ScriptFunction::Register<&PollNetworkClient>(rq, "PollNetworkClient"); | ||||
ScriptFunction::Register<&SetNetworkGameAttributes>(rq, "SetNetworkGameAttributes"); | ScriptFunction::Register<&SendGameSetupMessage>(rq, "SendGameSetupMessage"); | ||||
ScriptFunction::Register<&AssignNetworkPlayer>(rq, "AssignNetworkPlayer"); | ScriptFunction::Register<&AssignNetworkPlayer>(rq, "AssignNetworkPlayer"); | ||||
ScriptFunction::Register<&KickPlayer>(rq, "KickPlayer"); | ScriptFunction::Register<&KickPlayer>(rq, "KickPlayer"); | ||||
ScriptFunction::Register<&SendNetworkChat>(rq, "SendNetworkChat"); | ScriptFunction::Register<&SendNetworkChat>(rq, "SendNetworkChat"); | ||||
ScriptFunction::Register<&SendNetworkReady>(rq, "SendNetworkReady"); | ScriptFunction::Register<&SendNetworkReady>(rq, "SendNetworkReady"); | ||||
ScriptFunction::Register<&ClearAllPlayerReady>(rq, "ClearAllPlayerReady"); | ScriptFunction::Register<&ClearAllPlayerReady>(rq, "ClearAllPlayerReady"); | ||||
ScriptFunction::Register<&StartNetworkGame>(rq, "StartNetworkGame"); | ScriptFunction::Register<&StartNetworkGame>(rq, "StartNetworkGame"); | ||||
ScriptFunction::Register<&SetTurnLength>(rq, "SetTurnLength"); | ScriptFunction::Register<&SetTurnLength>(rq, "SetTurnLength"); | ||||
} | } | ||||
} | } |
Wildfire Games · Phabricator