Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.cpp
Show First 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | |||||
void CNetClient::SetUserName(const CStrW& username) | void CNetClient::SetUserName(const CStrW& username) | ||||
{ | { | ||||
ENSURE(!m_Session); // must be called before we start the connection | ENSURE(!m_Session); // must be called before we start the connection | ||||
m_UserName = username; | m_UserName = username; | ||||
} | } | ||||
void CNetClient::SetHostingPlayerName(const CStr& hostingPlayerName) | void CNetClient::SetHostJID(const CStr& HostJID) | ||||
{ | { | ||||
m_HostingPlayerName = hostingPlayerName; | m_HostJID = HostJID; | ||||
} | } | ||||
bool CNetClient::SetupConnection(const CStr& server, const u16 port, ENetHost* enetClient) | bool CNetClient::SetupConnection(const CStr& server, const u16 port, ENetHost* enetClient) | ||||
{ | { | ||||
CNetClientSession* session = new CNetClientSession(*this); | CNetClientSession* session = new CNetClientSession(*this); | ||||
bool ok = session->Connect(server, port, m_IsLocalClient, enetClient); | bool ok = session->Connect(server, port, m_IsLocalClient, enetClient); | ||||
SetAndOwnSession(session); | SetAndOwnSession(session); | ||||
return ok; | return ok; | ||||
▲ Show 20 Lines • Show All 355 Lines • ▼ Show 20 Lines | bool CNetClient::OnHandshakeResponse(void* context, CFsmEvent* event) | ||||
CNetClient* client = (CNetClient*)context; | CNetClient* client = (CNetClient*)context; | ||||
CSrvHandshakeResponseMessage* message = (CSrvHandshakeResponseMessage*)event->GetParamRef(); | CSrvHandshakeResponseMessage* message = (CSrvHandshakeResponseMessage*)event->GetParamRef(); | ||||
client->m_GUID = message->m_GUID; | client->m_GUID = message->m_GUID; | ||||
if (message->m_Flags & PS_NETWORK_FLAG_REQUIRE_LOBBYAUTH) | if (message->m_Flags & PS_NETWORK_FLAG_REQUIRE_LOBBYAUTH) | ||||
{ | { | ||||
if (g_XmppClient && !client->m_HostingPlayerName.empty()) | if (g_XmppClient && !client->m_HostJID.empty()) | ||||
g_XmppClient->SendIqLobbyAuth(client->m_HostingPlayerName, client->m_GUID); | g_XmppClient->SendIqLobbyAuth(client->m_HostJID, client->m_GUID); | ||||
else | else | ||||
{ | { | ||||
JSContext* cx = client->GetScriptInterface().GetContext(); | JSContext* cx = client->GetScriptInterface().GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
JS::RootedValue msg(cx); | JS::RootedValue msg(cx); | ||||
client->GetScriptInterface().Eval("({'type':'netstatus','status':'disconnected'})", &msg); | client->GetScriptInterface().Eval("({'type':'netstatus','status':'disconnected'})", &msg); | ||||
client->GetScriptInterface().SetProperty(msg, "reason", (int)NDR_LOBBY_AUTH_FAILED, false); | client->GetScriptInterface().SetProperty(msg, "reason", (int)NDR_LOBBY_AUTH_FAILED, false); | ||||
▲ Show 20 Lines • Show All 380 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator