Changeset View
Changeset View
Standalone View
Standalone View
source/network/scripting/JSInterface_Network.cpp
Show First 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | void StartNetworkJoin(const ScriptRequest& rq, const CStrW& playerName, const CStr& serverAddress, u16 serverPort) | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Requires XmppClient to send iq request to the server to get server's ip and port based on passed password. | * Requires XmppClient to send iq request to the server to get server's ip and port based on passed password. | ||||
* This is needed to not force server to share it's public ip with all potential clients in the lobby. | * This is needed to not force server to share it's public ip with all potential clients in the lobby. | ||||
* XmppClient will also handle logic after receiving the answer. | * XmppClient will also handle logic after receiving the answer. | ||||
*/ | */ | ||||
void StartNetworkJoinLobby(const CStrW& playerName, const CStr& hostJID, const CStr& password) | void StartNetworkJoinLobby(const CStrW& playerName, const CStr& hostJID, const CStr& password, const std::string& secret) | ||||
{ | { | ||||
ENSURE(!!g_XmppClient); | ENSURE(!!g_XmppClient); | ||||
ENSURE(!g_NetClient); | ENSURE(!g_NetClient); | ||||
ENSURE(!g_NetServer); | ENSURE(!g_NetServer); | ||||
ENSURE(!g_Game); | ENSURE(!g_Game); | ||||
CStr hashedPass = HashPassword(password); | CStr hashedPass = HashPassword(password); | ||||
g_Game = new CGame(true); | g_Game = new CGame(true); | ||||
g_NetClient = new CNetClient(g_Game); | g_NetClient = new CNetClient(g_Game); | ||||
g_NetClient->SetUserName(playerName); | g_NetClient->SetUserName(playerName); | ||||
g_NetClient->SetHostJID(hostJID); | g_NetClient->SetHostJID(hostJID); | ||||
g_NetClient->SetGamePassword(hashedPass); | g_NetClient->SetGamePassword(hashedPass); | ||||
g_NetClient->SetControllerSecret(secret); | |||||
g_XmppClient->SendIqGetConnectionData(hostJID, hashedPass.c_str(), false); | g_XmppClient->SendIqGetConnectionData(hostJID, hashedPass.c_str(), false); | ||||
} | } | ||||
void DisconnectNetworkGame() | void DisconnectNetworkGame() | ||||
{ | { | ||||
// TODO: we ought to do async reliable disconnections | // TODO: we ought to do async reliable disconnections | ||||
SAFE_DELETE(g_NetServer); | SAFE_DELETE(g_NetServer); | ||||
▲ Show 20 Lines • Show All 110 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator