Remove IXmppClient.h
Some checks failed
checkrefs / lfscheck (push) Has been cancelled
checkrefs / checkrefs (push) Has been cancelled
lint / cppcheck (push) Has been cancelled
lint / copyright (push) Has been cancelled
lint / jenkinsfiles (push) Has been cancelled
pre-commit / build (push) Has been cancelled

This is now possible after 0a455fbe2d.
This commit is contained in:
phosit 2026-03-19 18:36:52 +01:00
parent 1da954d455
commit 7758c98e7c
No known key found for this signature in database
GPG key ID: C9430B600671C268
11 changed files with 299 additions and 346 deletions

View file

@ -36,7 +36,7 @@
#include "lib/external_libraries/libsdl.h"
#include "lib/input.h"
#include "lib/posix/posix_types.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "maths/BoundingBoxAligned.h"
#include "maths/Frustum.h"
#include "maths/Vector3D.h"

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -17,7 +17,7 @@
#include "precompiled.h"
#include "IXmppClient.h"
#include "XmppClient.h"
IXmppClient *g_XmppClient = nullptr;
XmppClient *g_XmppClient = nullptr;
bool g_rankedGame = false;

View file

@ -1,74 +0,0 @@
/* Copyright (C) 2025 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IXMPPCLIENT_H
#define IXMPPCLIENT_H
#include "lib/types.h"
#include <js/Value.h>
class ScriptInterface;
class ScriptRequest;
class IXmppClient
{
public:
static IXmppClient* create(const ScriptInterface* scriptInterface, const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize = 0, bool regOpt = false);
virtual ~IXmppClient() {}
virtual void connect() = 0;
virtual void disconnect() = 0;
virtual bool isConnected() = 0;
virtual void recv() = 0;
virtual void SendIqGetBoardList() = 0;
virtual void SendIqGetProfile(const std::string& player) = 0;
virtual void SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data) = 0;
virtual void SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue data) = 0;
virtual void SendIqGetConnectionData(const std::string& jid, const std::string& password, const std::string& clientSalt, bool localIP) = 0;
virtual void SendIqUnregisterGame() = 0;
virtual void SendIqChangeStateGame(const std::string& nbp, const std::string& players) = 0;
virtual void SendIqLobbyAuth(const std::string& to, const std::string& token) = 0;
virtual void SetNick(const std::string& nick) = 0;
virtual std::string GetNick() const = 0;
virtual std::string GetJID() = 0;
virtual std::string GetUsername() const = 0;
virtual void ChangePassword(const std::string& newPassword) = 0;
virtual void kick(const std::string& nick, const std::string& reason) = 0;
virtual void ban(const std::string& nick, const std::string& reason) = 0;
virtual void SetPresence(const std::string& presence) = 0;
virtual const char* GetPresence(const std::string& nickname) = 0;
virtual const char* GetRole(const std::string& nickname) = 0;
virtual std::wstring GetRating(const std::string& nickname) = 0;
virtual const std::wstring& GetSubject() = 0;
virtual JS::Value GUIGetPlayerList(const ScriptRequest& rq) = 0;
virtual JS::Value GUIGetGameList(const ScriptRequest& rq) = 0;
virtual JS::Value GUIGetBoardList(const ScriptRequest& rq) = 0;
virtual JS::Value GUIGetProfile(const ScriptRequest& rq) = 0;
virtual JS::Value GuiPollNewMessages(const ScriptInterface& guiInterface) = 0;
virtual JS::Value GuiPollHistoricMessages(const ScriptInterface& guiInterface) = 0;
virtual bool GuiPollHasPlayerListUpdate() = 0;
virtual void SendMUCMessage(const std::string& message) = 0;
virtual void SendStunEndpointToHost(const std::string& ip, u16 port, const std::string& hostJID) = 0;
};
extern IXmppClient *g_XmppClient;
extern bool g_rankedGame;
#endif // XMPPCLIENT_H

View file

@ -21,10 +21,11 @@
#include "StanzaExtensions.h"
#include "i18n/L10n.h"
#include "lib/code_annotation.h"
#include "lib/external_libraries/gloox.h"
#include "lib/types.h"
#include "lib/utf8.h"
#include "lobby/GlooxConversion.h"
#include "lobby/IXmppClient.h"
#include "network/NetClient.h"
#include "network/NetServer.h"
#include "network/StunClient.h"
@ -39,14 +40,24 @@
#include "scriptinterface/ScriptRequest.h"
#include "scriptinterface/StructuredClone.h"
#include <ctime>
#include <deque>
#include <iostream>
#include <js/GCVector.h>
#include <js/PropertyAndElement.h>
#include <js/PropertyDescriptor.h>
#include <memory>
#include <js/TracingAPI.h>
#include <js/TypeDecls.h>
#include <js/Value.h>
#include <js/Vector.h>
#include <map>
#include <optional>
#include <string>
#include <tuple>
#include <unicode/locid.h>
#include <unicode/utypes.h>
#include <utility>
#include <vector>
namespace
{
@ -116,10 +127,135 @@ std::optional<gloox::MUCRoom> CreateMucRoom(gloox::MUCRoomHandler* handler, cons
}
} // anonymous namespace
IXmppClient* IXmppClient::create(const ScriptInterface* scriptInterface, const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize,bool regOpt)
class XmppClient::Impl : public gloox::ConnectionListener, public gloox::MUCRoomHandler,
public gloox::IqHandler, public gloox::RegistrationHandler, public gloox::MessageHandler,
public gloox::Jingle::SessionHandler, public gloox::LogHandler
{
return new XmppClient(scriptInterface, sUsername, sPassword, sRoom, sNick, historyRequestSize, regOpt);
}
public:
// Basic
Impl(const ScriptInterface* scriptInterface, const std::string& sUsername,
const std::string& sPassword, const std::string& sRoom, const std::string& sNick,
const int historyRequestSize, const bool regOpt);
std::string m_server;
// Components
gloox::Client m_client;
std::optional<gloox::MUCRoom> m_mucRoom;
gloox::Registration m_registration;
gloox::Jingle::SessionManager m_sessionManager;
// Account infos
std::string m_username;
std::string m_password;
std::string m_room;
std::string m_nick;
std::string m_xpartamuppId;
std::string m_echelonId;
// Security
std::string m_connectionDataJid;
std::string m_connectionDataIqId;
// State
gloox::CertStatus m_certStatus;
bool m_initialLoadComplete;
bool m_regOpt;
private:
/* Xmpp handlers */
/* MUC handlers */
void handleMUCParticipantPresence(gloox::MUCRoom* room, gloox::MUCRoomParticipant,
const gloox::Presence&) override;
void handleMUCError(gloox::MUCRoom* room, gloox::StanzaError) override;
void handleMUCMessage(gloox::MUCRoom* room, const gloox::Message& msg, bool priv) override;
void handleMUCSubject(gloox::MUCRoom* room, const std::string& nick,
const std::string& subject) override;
// Currently unused, provide noop implemtation for pure virtual functions.
bool handleMUCRoomCreation(gloox::MUCRoom*) override { return false; }
void handleMUCInviteDecline(gloox::MUCRoom*, const gloox::JID&, const std::string&) override {}
void handleMUCInfo(gloox::MUCRoom*, int, const std::string&, const gloox::DataForm*) override {}
void handleMUCItems(gloox::MUCRoom*, const std::list<gloox::Disco::Item*,
std::allocator<gloox::Disco::Item*>>&) override {}
/* Log handler */
void handleLog(gloox::LogLevel level, gloox::LogArea area, const std::string& message) override;
/* ConnectionListener handlers*/
void onConnect() override;
void onDisconnect(gloox::ConnectionError e) override;
bool onTLSConnect(const gloox::CertInfo& info) override;
/* Iq Handlers */
bool handleIq(const gloox::IQ& iq) override;
void handleIqID(const gloox::IQ&, int) override {}
/* Registration Handlers */
void handleRegistrationFields(const gloox::JID& /*from*/, int fields,
std::string instructions) override;
#if GLOOXVERSION >= 0x010100
void handleRegistrationResult(const gloox::JID& /*from*/, gloox::RegistrationResult result,
const gloox::Error* /*error*/) override;
#else
void handleRegistrationResult(const gloox::JID& /*from*/, gloox::RegistrationResult result) override;
#endif
void handleAlreadyRegistered(const gloox::JID& /*from*/) override;
void handleDataForm(const gloox::JID& /*from*/, const gloox::DataForm& /*form*/) override;
void handleOOB(const gloox::JID& /*from*/, const gloox::OOB& oob) override;
/* Message Handler */
void handleMessage(const gloox::Message& msg, gloox::MessageSession* session) override;
/* Session Handler */
void handleSessionAction(gloox::Jingle::Action action, gloox::Jingle::Session* session,
const gloox::Jingle::Session::Jingle* jingle) override;
void handleSessionActionError(gloox::Jingle::Action /*action*/, gloox::Jingle::Session* /*session*/,
const gloox::Error* /*error*/) override {}
void handleIncomingSession(gloox::Jingle::Session* /*session*/) override {}
void handleSessionInitiation(gloox::Jingle::Session* session,
const gloox::Jingle::Session::Jingle* jingle);
template<typename... Args>
void CreateGUIMessage(
const std::string& type,
const std::string& level,
const std::time_t time,
Args const&... args);
struct SPlayer {
SPlayer(const gloox::Presence::PresenceType presence, const gloox::MUCRoomRole role,
const std::string& rating)
: m_Presence(presence), m_Role(role), m_Rating(rating)
{
}
gloox::Presence::PresenceType m_Presence;
gloox::MUCRoomRole m_Role;
std::string m_Rating;
};
using PlayerMap = std::map<std::string, SPlayer>;
public:
/// Map of players
PlayerMap m_PlayerMap;
/// Whether or not the playermap has changed since the last time the GUI checked.
bool m_PlayerMapUpdate;
/// List of games
std::vector<std::unique_ptr<const gloox::Tag>> m_GameList;
/// List of rankings
std::vector<std::unique_ptr<const gloox::Tag>> m_BoardList;
/// Profile data
std::vector<std::unique_ptr<const gloox::Tag>> m_Profile;
/// ScriptInterface to root the values
const ScriptInterface* m_ScriptInterface;
/// Queue of messages for the GUI
JS::PersistentRootedVector<JS::Value> m_GuiMessageQueue;
/// Cache of all GUI messages received since the login
JS::PersistentRootedVector<JS::Value> m_HistoricGuiMessages;
/// Current room subject/topic.
std::wstring m_Subject;
};
/**
* Construct the XMPP client.
@ -133,7 +269,16 @@ IXmppClient* IXmppClient::create(const ScriptInterface* scriptInterface, const s
* @param historyRequestSize Number of stanzas of room history to request.
* @param regOpt If we are just registering or not.
*/
XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize, bool regOpt)
XmppClient::XmppClient(const ScriptInterface* scriptInterface, const std::string& username,
const std::string& password, const std::string& room, const std::string& nick,
const int historyRequestSize, bool regOpt) :
m_Impl{std::make_unique<Impl>(scriptInterface, username, password, room, nick, historyRequestSize,
regOpt)}
{}
XmppClient::Impl::Impl(const ScriptInterface* scriptInterface, const std::string& sUsername,
const std::string& sPassword, const std::string& sRoom, const std::string& sNick,
const int historyRequestSize, bool regOpt)
: m_server{g_ConfigDB.Get("lobby.server", std::string{})},
// If we are connecting, use the full jid and a password
// If we are registering, only use the server name
@ -213,35 +358,35 @@ XmppClient::~XmppClient()
DbgXMPP("XmppClient destroyed");
// Workaround for memory leak in gloox 1.0/1.0.1
m_client.removePresenceExtension(gloox::ExtCaps);
m_Impl->m_client.removePresenceExtension(gloox::ExtCaps);
}
/// Network
void XmppClient::connect()
{
m_initialLoadComplete = false;
m_client.connect(false);
m_Impl->m_initialLoadComplete = false;
m_Impl->m_client.connect(false);
}
void XmppClient::disconnect()
{
m_client.disconnect();
m_Impl->m_client.disconnect();
}
bool XmppClient::isConnected()
{
return m_client.state() == gloox::StateConnected;
return m_Impl->m_client.state() == gloox::StateConnected;
}
void XmppClient::recv()
{
m_client.recv(1);
m_Impl->m_client.recv(1);
}
/**
* Log (debug) Handler
*/
void XmppClient::handleLog(gloox::LogLevel level, gloox::LogArea area, const std::string& message)
void XmppClient::Impl::handleLog(gloox::LogLevel level, gloox::LogArea area, const std::string& message)
{
std::cout << "log: level: " << level << ", area: " << area << ", message: " << message << std::endl;
}
@ -253,7 +398,7 @@ void XmppClient::handleLog(gloox::LogLevel level, gloox::LogArea area, const std
/**
* Handle connection
*/
void XmppClient::onConnect()
void XmppClient::Impl::onConnect()
{
if (m_mucRoom)
{
@ -268,7 +413,7 @@ void XmppClient::onConnect()
/**
* Handle disconnection
*/
void XmppClient::onDisconnect(gloox::ConnectionError error)
void XmppClient::Impl::onDisconnect(gloox::ConnectionError error)
{
// Make sure we properly leave the room so that
// everything works if we decide to come back later
@ -296,7 +441,7 @@ void XmppClient::onDisconnect(gloox::ConnectionError error)
/**
* Handle TLS connection.
*/
bool XmppClient::onTLSConnect(const gloox::CertInfo& info)
bool XmppClient::Impl::onTLSConnect(const gloox::CertInfo& info)
{
DbgXMPP("onTLSConnect:" <<
" status: " << info.status <<
@ -316,7 +461,7 @@ bool XmppClient::onTLSConnect(const gloox::CertInfo& info)
/**
* Handle MUC room errors
*/
void XmppClient::handleMUCError(gloox::MUCRoom*, gloox::StanzaError err)
void XmppClient::Impl::handleMUCError(gloox::MUCRoom*, gloox::StanzaError err)
{
DbgXMPP("MUC Error " << ": " << StanzaErrorToString(err));
CreateGUIMessage("system", "error", std::time(nullptr), "text", err);
@ -331,15 +476,15 @@ void XmppClient::handleMUCError(gloox::MUCRoom*, gloox::StanzaError err)
*/
void XmppClient::SendIqGetBoardList()
{
gloox::JID echelonJid(m_echelonId);
gloox::JID echelonJid(m_Impl->m_echelonId);
// Send IQ
BoardListQuery* b = new BoardListQuery();
b->m_Command = "getleaderboard";
gloox::IQ iq(gloox::IQ::Get, echelonJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Get, echelonJid, m_Impl->m_client.getID());
iq.addExtension(b);
DbgXMPP("SendIqGetBoardList [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/**
@ -347,15 +492,15 @@ void XmppClient::SendIqGetBoardList()
*/
void XmppClient::SendIqGetProfile(const std::string& player)
{
gloox::JID echelonJid(m_echelonId);
gloox::JID echelonJid(m_Impl->m_echelonId);
// Send IQ
ProfileQuery* b = new ProfileQuery();
b->m_Command = player;
gloox::IQ iq(gloox::IQ::Get, echelonJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Get, echelonJid, m_Impl->m_client.getID());
iq.addExtension(b);
DbgXMPP("SendIqGetProfile [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/**
@ -369,12 +514,12 @@ void XmppClient::SendIqGetConnectionData(const std::string& jid, const std::stri
connectionData->m_Password = password;
connectionData->m_ClientSalt = clientSalt;
connectionData->m_IsLocalIP = localIP ? "1" : "0";
gloox::IQ iq(gloox::IQ::Get, targetJID, m_client.getID());
gloox::IQ iq(gloox::IQ::Get, targetJID, m_Impl->m_client.getID());
iq.addExtension(connectionData);
m_connectionDataJid = iq.from().full();
m_connectionDataIqId = iq.id();
m_Impl->m_connectionDataJid = iq.from().full();
m_Impl->m_connectionDataIqId = iq.id();
DbgXMPP("SendIqGetConnectionData [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/**
@ -384,7 +529,7 @@ void XmppClient::SendIqGetConnectionData(const std::string& jid, const std::stri
*/
void XmppClient::SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data)
{
gloox::JID echelonJid(m_echelonId);
gloox::JID echelonJid(m_Impl->m_echelonId);
// Setup some base stanza attributes
GameReport* game = new GameReport();
@ -414,10 +559,10 @@ void XmppClient::SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data)
game->m_GameReport.emplace_back(report);
// Send IQ
gloox::IQ iq(gloox::IQ::Set, echelonJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Set, echelonJid, m_Impl->m_client.getID());
iq.addExtension(game);
DbgXMPP("SendGameReport [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
};
/**
@ -427,7 +572,7 @@ void XmppClient::SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data)
*/
void XmppClient::SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue data)
{
gloox::JID xpartamuppJid(m_xpartamuppId);
gloox::JID xpartamuppJid(m_Impl->m_xpartamuppId);
// Setup some base stanza attributes
std::unique_ptr<GameListQuery> g = std::make_unique<GameListQuery>();
@ -458,10 +603,10 @@ void XmppClient::SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue dat
g->m_GameList.emplace_back(game);
// Send IQ
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_Impl->m_client.getID());
iq.addExtension(g.release());
DbgXMPP("SendIqRegisterGame [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/**
@ -469,17 +614,17 @@ void XmppClient::SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue dat
*/
void XmppClient::SendIqUnregisterGame()
{
gloox::JID xpartamuppJid(m_xpartamuppId);
gloox::JID xpartamuppJid(m_Impl->m_xpartamuppId);
// Send IQ
GameListQuery* g = new GameListQuery();
g->m_Command = "unregister";
g->m_GameList.emplace_back(new gloox::Tag("game"));
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_Impl->m_client.getID());
iq.addExtension(g);
DbgXMPP("SendIqUnregisterGame [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/**
@ -491,7 +636,7 @@ void XmppClient::SendIqUnregisterGame()
*/
void XmppClient::SendIqChangeStateGame(const std::string& nbp, const std::string& players)
{
gloox::JID xpartamuppJid(m_xpartamuppId);
gloox::JID xpartamuppJid(m_Impl->m_xpartamuppId);
// Send IQ
GameListQuery* g = new GameListQuery();
@ -501,10 +646,10 @@ void XmppClient::SendIqChangeStateGame(const std::string& nbp, const std::string
game->addAttribute("players", players);
g->m_GameList.emplace_back(game);
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Set, xpartamuppJid, m_Impl->m_client.getID());
iq.addExtension(g);
DbgXMPP("SendIqChangeStateGame [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/*****************************************************
@ -520,17 +665,17 @@ void XmppClient::SendIqLobbyAuth(const std::string& to, const std::string& token
auth->m_Token = token;
gloox::JID clientJid(to);
gloox::IQ iq(gloox::IQ::Set, clientJid, m_client.getID());
gloox::IQ iq(gloox::IQ::Set, clientJid, m_Impl->m_client.getID());
iq.addExtension(auth);
DbgXMPP("SendIqLobbyAuth [" << tag_xml(iq) << "]");
m_client.send(iq);
m_Impl->m_client.send(iq);
}
/*****************************************************
* Account registration *
*****************************************************/
void XmppClient::handleRegistrationFields(const gloox::JID&, int fields, std::string)
void XmppClient::Impl::handleRegistrationFields(const gloox::JID&, int fields, std::string)
{
gloox::RegistrationFields vals;
vals.username = m_username;
@ -539,9 +684,10 @@ void XmppClient::handleRegistrationFields(const gloox::JID&, int fields, std::st
}
#if GLOOXVERSION >= 0x010100
void XmppClient::handleRegistrationResult(const gloox::JID&, gloox::RegistrationResult result, const gloox::Error* /*error*/)
void XmppClient::Impl::handleRegistrationResult(const gloox::JID&, gloox::RegistrationResult result,
const gloox::Error* /*error*/)
#else
void XmppClient::handleRegistrationResult(const gloox::JID&, gloox::RegistrationResult result)
void XmppClient::Impl::handleRegistrationResult(const gloox::JID&, gloox::RegistrationResult result)
#endif
{
if (result == gloox::RegistrationSuccess)
@ -550,17 +696,17 @@ void XmppClient::handleRegistrationResult(const gloox::JID&, gloox::Registration
CreateGUIMessage("system", "error", std::time(nullptr), "text", result);
}
void XmppClient::handleAlreadyRegistered(const gloox::JID&)
void XmppClient::Impl::handleAlreadyRegistered(const gloox::JID&)
{
DbgXMPP("the account already exists");
}
void XmppClient::handleDataForm(const gloox::JID&, const gloox::DataForm&)
void XmppClient::Impl::handleDataForm(const gloox::JID&, const gloox::DataForm&)
{
DbgXMPP("dataForm received");
}
void XmppClient::handleOOB(const gloox::JID&, const gloox::OOB&)
void XmppClient::Impl::handleOOB(const gloox::JID&, const gloox::OOB&)
{
DbgXMPP("OOB registration requested");
}
@ -578,7 +724,7 @@ JS::Value XmppClient::GUIGetPlayerList(const ScriptRequest& rq)
{
JS::RootedValueVector players{rq.cx};
for (const std::pair<const std::string, SPlayer>& p : m_PlayerMap)
for (const auto& p : m_Impl->m_PlayerMap)
{
JS::RootedValue player(rq.cx);
@ -609,7 +755,7 @@ JS::Value XmppClient::GUIGetGameList(const ScriptRequest& rq)
"nbp", "maxnbp", "players", "mapName", "niceMapName", "mapSize", "mapType",
"victoryConditions", "startTime", "mods" };
for(const std::unique_ptr<const gloox::Tag>& t : m_GameList)
for(const std::unique_ptr<const gloox::Tag>& t : m_Impl->m_GameList)
{
JS::RootedValue game(rq.cx);
Script::CreateObject(rq, &game);
@ -634,7 +780,7 @@ JS::Value XmppClient::GUIGetBoardList(const ScriptRequest& rq)
const char* attributes[] = { "name", "rank", "rating" };
for(const std::unique_ptr<const gloox::Tag>& t : m_BoardList)
for(const std::unique_ptr<const gloox::Tag>& t : m_Impl->m_BoardList)
{
JS::RootedValue board(rq.cx);
Script::CreateObject(rq, &board);
@ -659,7 +805,7 @@ JS::Value XmppClient::GUIGetProfile(const ScriptRequest& rq)
const char* stats[] = { "player", "rating", "totalGamesPlayed", "highestRating", "wins", "losses", "rank" };
for (const std::unique_ptr<const gloox::Tag>& t : m_Profile)
for (const std::unique_ptr<const gloox::Tag>& t : m_Impl->m_Profile)
{
JS::RootedValue profile(rq.cx);
Script::CreateObject(rq, &profile);
@ -691,7 +837,7 @@ void SetGUIMessageProperty(const ScriptRequest& rq, JS::HandleObject messageObj,
}
template<typename... Args>
void XmppClient::CreateGUIMessage(
void XmppClient::Impl::CreateGUIMessage(
const std::string& type,
const std::string& level,
const std::time_t time,
@ -720,24 +866,24 @@ bool XmppClient::GuiPollHasPlayerListUpdate()
{
// The initial playerlist will be received in multiple messages
// Only inform the GUI after all of these playerlist fragments were received.
if (!m_initialLoadComplete)
if (!m_Impl->m_initialLoadComplete)
return false;
return std::exchange(m_PlayerMapUpdate, false);
return std::exchange(m_Impl->m_PlayerMapUpdate, false);
}
JS::Value XmppClient::GuiPollNewMessages(const ScriptInterface& guiInterface)
{
if ((isConnected() && !m_initialLoadComplete) || m_GuiMessageQueue.empty())
if ((isConnected() && !m_Impl->m_initialLoadComplete) || m_Impl->m_GuiMessageQueue.empty())
return JS::UndefinedValue();
ScriptRequest rq(m_ScriptInterface);
ScriptRequest rq(m_Impl->m_ScriptInterface);
// Optimize for batch message processing that is more
// performance demanding than processing a lone message.
JS::RootedValueVector messages{rq.cx};
for (const JS::Value& message : m_GuiMessageQueue)
for (const JS::Value& message : m_Impl->m_GuiMessageQueue)
{
if (!messages.append(message))
throw std::runtime_error{"Append failed"};
@ -760,36 +906,36 @@ JS::Value XmppClient::GuiPollNewMessages(const ScriptInterface& guiInterface)
{
Script::SetProperty(rq, historicMessage, "historic", true);
Script::DeepFreezeObject(rq, historicMessage);
if (!m_HistoricGuiMessages.append(historicMessage))
if (!m_Impl->m_HistoricGuiMessages.append(historicMessage))
throw std::runtime_error{"Append failed"};
}
else
LOGERROR("Could not clone historic lobby GUI message!");
}
m_GuiMessageQueue.clear();
m_Impl->m_GuiMessageQueue.clear();
// Copy the messages over to the caller script interface.
return Script::CloneValueFromOtherCompartment(guiInterface, *m_ScriptInterface,
return Script::CloneValueFromOtherCompartment(guiInterface, *m_Impl->m_ScriptInterface,
JS::RootedValue{rq.cx, JS::ObjectValue(*JS::NewArrayObject(rq.cx, messages))});
}
JS::Value XmppClient::GuiPollHistoricMessages(const ScriptInterface& guiInterface)
{
if (m_HistoricGuiMessages.empty())
if (m_Impl->m_HistoricGuiMessages.empty())
return JS::UndefinedValue();
ScriptRequest rq(m_ScriptInterface);
ScriptRequest rq(m_Impl->m_ScriptInterface);
JS::RootedValueVector messages{rq.cx};
for (const JS::Value& message : m_HistoricGuiMessages)
for (const JS::Value& message : m_Impl->m_HistoricGuiMessages)
{
if (!messages.append(message))
throw std::runtime_error{"Append failed"};
}
// Copy the messages over to the caller script interface.
return Script::CloneValueFromOtherCompartment(guiInterface, *m_ScriptInterface,
return Script::CloneValueFromOtherCompartment(guiInterface, *m_Impl->m_ScriptInterface,
JS::RootedValue{rq.cx, JS::ObjectValue(*JS::NewArrayObject(rq.cx, messages))});
}
@ -798,13 +944,13 @@ JS::Value XmppClient::GuiPollHistoricMessages(const ScriptInterface& guiInterfac
*/
void XmppClient::SendMUCMessage(const std::string& message)
{
m_mucRoom->send(message);
m_Impl->m_mucRoom->send(message);
}
/**
* Handle a room message.
*/
void XmppClient::handleMUCMessage(gloox::MUCRoom*, const gloox::Message& msg, bool priv)
void XmppClient::Impl::handleMUCMessage(gloox::MUCRoom*, const gloox::Message& msg, bool priv)
{
DbgXMPP(msg.from().resource() << " said " << msg.body());
@ -819,7 +965,7 @@ void XmppClient::handleMUCMessage(gloox::MUCRoom*, const gloox::Message& msg, bo
/**
* Handle a private message.
*/
void XmppClient::handleMessage(const gloox::Message& msg, gloox::MessageSession*)
void XmppClient::Impl::handleMessage(const gloox::Message& msg, gloox::MessageSession*)
{
DbgXMPP("type " << msg.subtype() << ", subject " << msg.subject()
<< ", message " << msg.body() << ", thread id " << msg.thread());
@ -836,7 +982,7 @@ void XmppClient::handleMessage(const gloox::Message& msg, gloox::MessageSession*
/**
* Handle portions of messages containing custom stanza extensions.
*/
bool XmppClient::handleIq(const gloox::IQ& iq)
bool XmppClient::Impl::handleIq(const gloox::IQ& iq)
{
DbgXMPP("handleIq [" << tag_xml(iq) << "]");
@ -1029,7 +1175,7 @@ bool XmppClient::handleIq(const gloox::IQ& iq)
/**
* Update local data when a user changes presence.
*/
void XmppClient::handleMUCParticipantPresence(gloox::MUCRoom*, const gloox::MUCRoomParticipant participant,
void XmppClient::Impl::handleMUCParticipantPresence(gloox::MUCRoom*, const gloox::MUCRoomParticipant participant,
const gloox::Presence& presence)
{
const std::string& nick = participant.nick->resource();
@ -1150,7 +1296,7 @@ void XmppClient::handleMUCParticipantPresence(gloox::MUCRoom*, const gloox::MUCR
/**
* Update local cache when subject changes.
*/
void XmppClient::handleMUCSubject(gloox::MUCRoom*, const std::string& nick, const std::string& subject)
void XmppClient::Impl::handleMUCSubject(gloox::MUCRoom*, const std::string& nick, const std::string& subject)
{
m_Subject = wstring_from_utf8(subject);
@ -1167,7 +1313,7 @@ void XmppClient::handleMUCSubject(gloox::MUCRoom*, const std::string& nick, cons
*/
const std::wstring& XmppClient::GetSubject()
{
return m_Subject;
return m_Impl->m_Subject;
}
/**
@ -1177,7 +1323,7 @@ const std::wstring& XmppClient::GetSubject()
*/
void XmppClient::SetNick(const std::string& nick)
{
m_mucRoom->setNick(nick);
m_Impl->m_mucRoom->setNick(nick);
}
/**
@ -1185,12 +1331,12 @@ void XmppClient::SetNick(const std::string& nick)
*/
std::string XmppClient::GetNick() const
{
return m_mucRoom->nick();
return m_Impl->m_mucRoom->nick();
}
std::string XmppClient::GetJID()
{
return m_client.jid().full();
return m_Impl->m_client.jid().full();
}
@ -1201,7 +1347,7 @@ std::string XmppClient::GetJID()
*/
std::string XmppClient::GetUsername() const
{
return m_username;
return m_Impl->m_username;
}
/**
@ -1211,7 +1357,7 @@ std::string XmppClient::GetUsername() const
*/
void XmppClient::ChangePassword(const std::string& newPassword)
{
m_registration.changePassword(m_client.jid().username(), newPassword);
m_Impl->m_registration.changePassword(m_Impl->m_client.jid().username(), newPassword);
}
/**
@ -1222,7 +1368,7 @@ void XmppClient::ChangePassword(const std::string& newPassword)
*/
void XmppClient::kick(const std::string& nick, const std::string& reason)
{
m_mucRoom->kick(nick, reason);
m_Impl->m_mucRoom->kick(nick, reason);
}
/**
@ -1233,7 +1379,7 @@ void XmppClient::kick(const std::string& nick, const std::string& reason)
*/
void XmppClient::ban(const std::string& nick, const std::string& reason)
{
m_mucRoom->ban(nick, reason);
m_Impl->m_mucRoom->ban(nick, reason);
}
/**
@ -1243,7 +1389,7 @@ void XmppClient::ban(const std::string& nick, const std::string& reason)
*/
void XmppClient::SetPresence(const std::string& presence)
{
#define IF(x,y) if (presence == x) m_mucRoom->setPresence(gloox::Presence::y)
#define IF(x,y) if (presence == x) m_Impl->m_mucRoom->setPresence(gloox::Presence::y)
IF("available", Available);
else IF("chat", Chat);
else IF("away", Away);
@ -1259,9 +1405,9 @@ void XmppClient::SetPresence(const std::string& presence)
*/
const char* XmppClient::GetPresence(const std::string& nick)
{
const PlayerMap::iterator it = m_PlayerMap.find(nick);
const auto it = m_Impl->m_PlayerMap.find(nick);
if (it == m_PlayerMap.end())
if (it == m_Impl->m_PlayerMap.end())
return "offline";
return GetPresenceString(it->second.m_Presence);
@ -1272,9 +1418,9 @@ const char* XmppClient::GetPresence(const std::string& nick)
*/
const char* XmppClient::GetRole(const std::string& nick)
{
const PlayerMap::iterator it = m_PlayerMap.find(nick);
const auto it = m_Impl->m_PlayerMap.find(nick);
if (it == m_PlayerMap.end())
if (it == m_Impl->m_PlayerMap.end())
return "";
return GetRoleString(it->second.m_Role);
@ -1286,9 +1432,9 @@ const char* XmppClient::GetRole(const std::string& nick)
*/
std::wstring XmppClient::GetRating(const std::string& nick)
{
const PlayerMap::iterator it = m_PlayerMap.find(nick);
const auto it = m_Impl->m_PlayerMap.find(nick);
if (it == m_PlayerMap.end())
if (it == m_Impl->m_PlayerMap.end())
return std::wstring();
return wstring_from_utf8(it->second.m_Rating);
@ -1303,7 +1449,7 @@ void XmppClient::SendStunEndpointToHost(const std::string& ip, u16 port, const s
DbgXMPP("SendStunEndpointToHost " << hostJIDStr);
gloox::JID hostJID(hostJIDStr);
gloox::Jingle::Session* session = m_sessionManager.createSession(hostJID, this);
gloox::Jingle::Session* session = m_Impl->m_sessionManager.createSession(hostJID, m_Impl.get());
gloox::Jingle::ICEUDP::CandidateList candidateList;
@ -1330,13 +1476,13 @@ void XmppClient::SendStunEndpointToHost(const std::string& ip, u16 port, const s
session->sessionInitiate(new gloox::Jingle::Content(std::string("game-data"), pluginList));
}
void XmppClient::handleSessionAction(gloox::Jingle::Action action, gloox::Jingle::Session* session, const gloox::Jingle::Session::Jingle* jingle)
void XmppClient::Impl::handleSessionAction(gloox::Jingle::Action action, gloox::Jingle::Session* session, const gloox::Jingle::Session::Jingle* jingle)
{
if (action == gloox::Jingle::SessionInitiate)
handleSessionInitiation(session, jingle);
}
void XmppClient::handleSessionInitiation(gloox::Jingle::Session*,
void XmppClient::Impl::handleSessionInitiation(gloox::Jingle::Session*,
const gloox::Jingle::Session::Jingle* jingle)
{
gloox::Jingle::ICEUDP::Candidate candidate{};

View file

@ -18,185 +18,65 @@
#ifndef XXXMPPCLIENT_H
#define XXXMPPCLIENT_H
#include "IXmppClient.h"
#include "lib/code_annotation.h"
#include "lib/external_libraries/gloox.h"
#include "lib/types.h"
#include <ctime>
#include <deque>
#include <js/RootingAPI.h>
#include <js/TypeDecls.h>
#include <js/Value.h>
#include <js/Vector.h>
#include <js/GCVector.h>
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <vector>
class ScriptInterface;
class ScriptRequest;
class XmppClient : public IXmppClient, public gloox::ConnectionListener, public gloox::MUCRoomHandler, public gloox::IqHandler, public gloox::RegistrationHandler, public gloox::MessageHandler, public gloox::Jingle::SessionHandler, public gloox::LogHandler
class XmppClient
{
NONCOPYABLE(XmppClient);
private:
std::string m_server;
// Components
gloox::Client m_client;
std::optional<gloox::MUCRoom> m_mucRoom;
gloox::Registration m_registration;
gloox::Jingle::SessionManager m_sessionManager;
// Account infos
std::string m_username;
std::string m_password;
std::string m_room;
std::string m_nick;
std::string m_xpartamuppId;
std::string m_echelonId;
// Security
std::string m_connectionDataJid;
std::string m_connectionDataIqId;
// State
gloox::CertStatus m_certStatus;
bool m_initialLoadComplete;
bool m_regOpt;
public:
// Basic
XmppClient(const ScriptInterface* scriptInterface, const std::string& sUsername, const std::string& sPassword, const std::string& sRoom, const std::string& sNick, const int historyRequestSize = 0, const bool regOpt = false);
virtual ~XmppClient();
XmppClient(const ScriptInterface* scriptInterface, const std::string& username,
const std::string& password, const std::string& room, const std::string& nick,
const int historyRequestSize = 0, bool regOpt = false);
~XmppClient();
// Network
void connect() override;
void disconnect() override;
bool isConnected() override;
void recv() override;
void SendIqGetBoardList() override;
void SendIqGetProfile(const std::string& player) override;
void SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data) override;
void SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue data) override;
void SendIqGetConnectionData(const std::string& jid, const std::string& password, const std::string& clientSalt, bool localIP) override;
void SendIqUnregisterGame() override;
void SendIqChangeStateGame(const std::string& nbp, const std::string& players) override;
void SendIqLobbyAuth(const std::string& to, const std::string& token) override;
void SetNick(const std::string& nick) override;
std::string GetNick() const override;
std::string GetJID() override;
std::string GetUsername() const override;
void ChangePassword(const std::string& newPassword) override;
void kick(const std::string& nick, const std::string& reason) override;
void ban(const std::string& nick, const std::string& reason) override;
void SetPresence(const std::string& presence) override;
const char* GetPresence(const std::string& nickname) override;
const char* GetRole(const std::string& nickname) override;
std::wstring GetRating(const std::string& nickname) override;
const std::wstring& GetSubject() override;
void connect();
void disconnect();
bool isConnected();
void recv();
void SendIqGetBoardList();
void SendIqGetProfile(const std::string& player);
void SendIqGameReport(const ScriptRequest& rq, JS::HandleValue data);
void SendIqRegisterGame(const ScriptRequest& rq, JS::HandleValue data);
void SendIqGetConnectionData(const std::string& jid, const std::string& password,
const std::string& clientSalt, bool localIP);
void SendIqUnregisterGame();
void SendIqChangeStateGame(const std::string& nbp, const std::string& players);
void SendIqLobbyAuth(const std::string& to, const std::string& token);
void SetNick(const std::string& nick);
std::string GetNick() const;
std::string GetJID();
std::string GetUsername() const;
void ChangePassword(const std::string& newPassword);
void kick(const std::string& nick, const std::string& reason);
void ban(const std::string& nick, const std::string& reason);
void SetPresence(const std::string& presence);
const char* GetPresence(const std::string& nickname);
const char* GetRole(const std::string& nickname);
std::wstring GetRating(const std::string& nickname);
const std::wstring& GetSubject();
JS::Value GUIGetPlayerList(const ScriptRequest& rq);
JS::Value GUIGetGameList(const ScriptRequest& rq);
JS::Value GUIGetBoardList(const ScriptRequest& rq);
JS::Value GUIGetProfile(const ScriptRequest& rq);
JS::Value GUIGetPlayerList(const ScriptRequest& rq) override;
JS::Value GUIGetGameList(const ScriptRequest& rq) override;
JS::Value GUIGetBoardList(const ScriptRequest& rq) override;
JS::Value GUIGetProfile(const ScriptRequest& rq) override;
JS::Value GuiPollNewMessages(const ScriptInterface& guiInterface);
JS::Value GuiPollHistoricMessages(const ScriptInterface& guiInterface);
bool GuiPollHasPlayerListUpdate();
void SendStunEndpointToHost(const std::string& ip, u16 port, const std::string& hostJID) override;
protected:
/* Xmpp handlers */
/* MUC handlers */
void handleMUCParticipantPresence(gloox::MUCRoom* room, gloox::MUCRoomParticipant, const gloox::Presence&) override;
void handleMUCError(gloox::MUCRoom* room, gloox::StanzaError) override;
void handleMUCMessage(gloox::MUCRoom* room, const gloox::Message& msg, bool priv) override;
void handleMUCSubject(gloox::MUCRoom* room, const std::string& nick, const std::string& subject) override;
// Currently unused, provide noop implemtation for pure virtual functions.
bool handleMUCRoomCreation(gloox::MUCRoom*) override { return false; }
void handleMUCInviteDecline(gloox::MUCRoom*, const gloox::JID&, const std::string&) override {}
void handleMUCInfo(gloox::MUCRoom*, int, const std::string&, const gloox::DataForm*) override {}
void handleMUCItems(gloox::MUCRoom*, const std::list<gloox::Disco::Item*, std::allocator<gloox::Disco::Item*> >&) override {}
/* Log handler */
void handleLog(gloox::LogLevel level, gloox::LogArea area, const std::string& message) override;
/* ConnectionListener handlers*/
void onConnect() override;
void onDisconnect(gloox::ConnectionError e) override;
bool onTLSConnect(const gloox::CertInfo& info) override;
/* Iq Handlers */
bool handleIq(const gloox::IQ& iq) override;
void handleIqID(const gloox::IQ&, int) override {}
/* Registration Handlers */
void handleRegistrationFields(const gloox::JID& /*from*/, int fields, std::string instructions ) override;
#if GLOOXVERSION >= 0x010100
void handleRegistrationResult(const gloox::JID& /*from*/, gloox::RegistrationResult result, const gloox::Error* /*error*/) override;
#else
void handleRegistrationResult(const gloox::JID& /*from*/, gloox::RegistrationResult result) override;
#endif
void handleAlreadyRegistered(const gloox::JID& /*from*/) override;
void handleDataForm(const gloox::JID& /*from*/, const gloox::DataForm& /*form*/) override;
void handleOOB(const gloox::JID& /*from*/, const gloox::OOB& oob) override;
/* Message Handler */
void handleMessage(const gloox::Message& msg, gloox::MessageSession* session) override;
/* Session Handler */
void handleSessionAction(gloox::Jingle::Action action, gloox::Jingle::Session* session, const gloox::Jingle::Session::Jingle* jingle) override;
void handleSessionActionError(gloox::Jingle::Action /*action*/, gloox::Jingle::Session* /*session*/, const gloox::Error* /*error*/) override {}
void handleIncomingSession(gloox::Jingle::Session* /*session*/) override {}
private:
void handleSessionInitiation(gloox::Jingle::Session* session, const gloox::Jingle::Session::Jingle* jingle);
public:
JS::Value GuiPollNewMessages(const ScriptInterface& guiInterface) override;
JS::Value GuiPollHistoricMessages(const ScriptInterface& guiInterface) override;
bool GuiPollHasPlayerListUpdate() override;
void SendMUCMessage(const std::string& message) override;
protected:
template<typename... Args>
void CreateGUIMessage(
const std::string& type,
const std::string& level,
const std::time_t time,
Args const&... args);
void SendMUCMessage(const std::string& message);
void SendStunEndpointToHost(const std::string& ip, u16 port, const std::string& hostJID);
private:
struct SPlayer {
SPlayer(const gloox::Presence::PresenceType presence, const gloox::MUCRoomRole role, const std::string& rating)
: m_Presence(presence), m_Role(role), m_Rating(rating)
{
}
gloox::Presence::PresenceType m_Presence;
gloox::MUCRoomRole m_Role;
std::string m_Rating;
};
using PlayerMap = std::map<std::string, SPlayer>;
/// Map of players
PlayerMap m_PlayerMap;
/// Whether or not the playermap has changed since the last time the GUI checked.
bool m_PlayerMapUpdate;
/// List of games
std::vector<std::unique_ptr<const gloox::Tag>> m_GameList;
/// List of rankings
std::vector<std::unique_ptr<const gloox::Tag>> m_BoardList;
/// Profile data
std::vector<std::unique_ptr<const gloox::Tag>> m_Profile;
/// ScriptInterface to root the values
const ScriptInterface* m_ScriptInterface;
/// Queue of messages for the GUI
JS::PersistentRootedVector<JS::Value> m_GuiMessageQueue;
/// Cache of all GUI messages received since the login
JS::PersistentRootedVector<JS::Value> m_HistoricGuiMessages;
/// Current room subject/topic.
std::wstring m_Subject;
class Impl;
const std::unique_ptr<Impl> m_Impl;
};
extern XmppClient *g_XmppClient;
extern bool g_rankedGame;
#endif // XMPPCLIENT_H

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -25,7 +25,7 @@
#include "lib/config2.h"
#include "lib/debug.h"
#include "lib/utf8.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "network/NetServer.h"
#include "ps/CLogger.h"
#include "ps/CStr.h"
@ -65,13 +65,13 @@ void StartXmppClient(const std::wstring& username, const std::wstring& password,
throw std::logic_error{"Cannot call StartXmppClient with an already initialized XmppClient!"};
g_XmppClient =
IXmppClient::create(
new XmppClient{
&g_GUI->GetScriptInterface(),
utf8_from_wstring(username),
utf8_from_wstring(password),
utf8_from_wstring(room),
utf8_from_wstring(nick),
historyRequestSize);
historyRequestSize};
g_rankedGame = true;
}
@ -85,14 +85,14 @@ void StartRegisterXmppClient(const std::wstring& username, const std::wstring& p
}
g_XmppClient =
IXmppClient::create(
new XmppClient{
&g_GUI->GetScriptInterface(),
utf8_from_wstring(username),
utf8_from_wstring(password),
std::string(),
std::string(),
0,
true);
true};
}
void StopXmppClient()
@ -107,7 +107,7 @@ void StopXmppClient()
////////////////////////////////////////////////
////////////////////////////////////////////////
IXmppClient* XmppGetter(const ScriptRequest&, JS::CallArgs&)
XmppClient* XmppGetter(const ScriptRequest&, JS::CallArgs&)
{
if (!g_XmppClient)
{
@ -197,7 +197,7 @@ void RegisterScriptFunctions(const ScriptRequest& rq)
ScriptFunction::Register<&StopXmppClient>(rq, "StopXmppClient");
#define REGISTER_XMPP(func, name) \
ScriptFunction::Register<&IXmppClient::func, &XmppGetter>(rq, name)
ScriptFunction::Register<&XmppClient::func, &XmppGetter>(rq, name)
REGISTER_XMPP(connect, "ConnectXmppClient");
REGISTER_XMPP(disconnect, "DisconnectXmppClient");

View file

@ -50,7 +50,7 @@ that of Atlas depending on commandline parameters.
#include "lib/sysdep/os.h"
#include "lib/timer.h"
#include "lib/types.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "network/NetClient.h"
#include "ps/ArchiveBuilder.h"
#include "ps/CConsole.h"

View file

@ -24,7 +24,7 @@
#include "lib/external_libraries/enet.h"
#include "lib/status.h"
#include "lib/utf8.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "network/NetClientSession.h"
#include "network/NetClientTurnManager.h"
#include "network/NetEnet.h"
@ -151,7 +151,7 @@ CNetClient::CNetClient(PrivateTag, CGame* game, std::string serverAddressOrHostn
}
CNetClient::CNetClient(CGame* game, const CStrW& username, const CStr& hostJID,
std::string hashedPassword, IXmppClient& xmppClient) :
std::string hashedPassword, XmppClient& xmppClient) :
CNetClient{PrivateTag{}, game, {}, 0, username, hostJID, std::move(hashedPassword)}
{
xmppClient.SendIqGetConnectionData(m_HostJID, m_Password, m_UserName.ToUTF8(), false);

View file

@ -44,7 +44,7 @@ class CNetClientSession;
class CNetClientTurnManager;
class JSTracer;
class ScriptInterface;
class IXmppClient;
class XmppClient;
typedef struct _ENetHost ENetHost;
@ -88,7 +88,7 @@ public:
* lobby.
*/
CNetClient(CGame* game, const CStrW& username, const CStr& hostJID,
std::string hashedPassword, IXmppClient& xmppClient);
std::string hashedPassword, XmppClient& xmppClient);
virtual ~CNetClient();
@ -377,3 +377,4 @@ private:
extern CNetClient *g_NetClient;
#endif // NETCLIENT_H

View file

@ -23,7 +23,7 @@
#include "lib/debug.h"
#include "lib/types.h"
#include "lib/utf8.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "network/NetClient.h"
#include "network/NetMessage.h"
#include "network/NetServer.h"

View file

@ -40,7 +40,7 @@
#include "lib/status.h"
#include "lib/sysdep/os.h"
#include "lib/timer.h"
#include "lobby/IXmppClient.h"
#include "lobby/XmppClient.h"
#include "network/NetClient.h"
#include "network/NetHost.h"
#include "network/NetMessage.h"