Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/XmppClient.cpp
Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | |||||
/***************************************************** | /***************************************************** | ||||
* iq to clients * | * iq to clients * | ||||
*****************************************************/ | *****************************************************/ | ||||
/** | /** | ||||
* Send lobby authentication token. | * Send lobby authentication token. | ||||
*/ | */ | ||||
void XmppClient::SendIqLobbyAuth(const std::string& to, const std::string& token) | void XmppClient::SendIqLobbyAuth(const std::string& hostJIDStr, const std::string& token) | ||||
{ | { | ||||
LobbyAuth* auth = new LobbyAuth(); | LobbyAuth* auth = new LobbyAuth(); | ||||
auth->m_Token = token; | auth->m_Token = token; | ||||
glooxwrapper::JID clientJid(to + "@" + m_server + "/0ad"); | glooxwrapper::JID hostJID(hostJIDStr); | ||||
glooxwrapper::IQ iq(gloox::IQ::Set, clientJid, m_client->getID()); | glooxwrapper::IQ iq(gloox::IQ::Set, hostJID, m_client->getID()); | ||||
iq.addExtension(auth); | iq.addExtension(auth); | ||||
DbgXMPP("SendIqLobbyAuth [" << tag_xml(iq) << "]"); | DbgXMPP("SendIqLobbyAuth [" << tag_xml(iq) << "]"); | ||||
m_client->send(iq); | m_client->send(iq); | ||||
} | } | ||||
/***************************************************** | /***************************************************** | ||||
* Account registration * | * Account registration * | ||||
*****************************************************/ | *****************************************************/ | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
* @return A JS array containing all known games | * @return A JS array containing all known games | ||||
*/ | */ | ||||
void XmppClient::GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | void XmppClient::GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret) | ||||
{ | { | ||||
JSContext* cx = scriptInterface.GetContext(); | JSContext* cx = scriptInterface.GetContext(); | ||||
JSAutoRequest rq(cx); | JSAutoRequest rq(cx); | ||||
scriptInterface.Eval("([])", ret); | scriptInterface.Eval("([])", ret); | ||||
const char* stats[] = { "name", "ip", "port", "stunIP", "stunPort", "hostUsername", "state", | const char* stats[] = { "name", "ip", "port", "stunIP", "stunPort", "hostJID", "state", | ||||
"nbp", "maxnbp", "players", "mapName", "niceMapName", "mapSize", "mapType", | "nbp", "maxnbp", "players", "mapName", "niceMapName", "mapSize", "mapType", | ||||
"victoryCondition", "startTime", "mods" }; | "victoryCondition", "startTime", "mods" }; | ||||
for(const glooxwrapper::Tag* const& t : m_GameList) | for(const glooxwrapper::Tag* const& t : m_GameList) | ||||
{ | { | ||||
JS::RootedValue game(cx); | JS::RootedValue game(cx); | ||||
scriptInterface.Eval("({})", &game); | scriptInterface.Eval("({})", &game); | ||||
for (size_t i = 0; i < ARRAY_SIZE(stats); ++i) | for (size_t i = 0; i < ARRAY_SIZE(stats); ++i) | ||||
▲ Show 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | |||||
* | * | ||||
* @param nick Variable to store the nickname in. | * @param nick Variable to store the nickname in. | ||||
*/ | */ | ||||
void XmppClient::GetNick(std::string& nick) | void XmppClient::GetNick(std::string& nick) | ||||
{ | { | ||||
nick = m_mucRoom->nick().to_string(); | nick = m_mucRoom->nick().to_string(); | ||||
} | } | ||||
void XmppClient::GetRoomJID(std::string& jid) | |||||
{ | |||||
// TODO: add new getter? | |||||
jid = m_client->getWrapped()->jid().full(); | |||||
} | |||||
/** | /** | ||||
* Kick a player from the current room. | * Kick a player from the current room. | ||||
* | * | ||||
* @param nick Nickname to be kicked | * @param nick Nickname to be kicked | ||||
* @param reason Reason the player was kicked | * @param reason Reason the player was kicked | ||||
*/ | */ | ||||
void XmppClient::kick(const std::string& nick, const std::string& reason) | void XmppClient::kick(const std::string& nick, const std::string& reason) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 314 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator