Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
XmppClient Class Reference

#include <XmppClient.h>

Classes

class  Impl
 

Public Member Functions

 XmppClient (const Script::Interface *scriptInterface, const std::string &username, const std::string &password, const std::string &room, const std::string &nick, const int historyRequestSize=0, bool regOpt=false)
 Construct the XMPP client. More...
 
 ~XmppClient ()
 Destroy the xmpp client. More...
 
void connect ()
 Network. More...
 
void disconnect ()
 
bool isConnected ()
 
void recv ()
 
void SendIqGetBoardList ()
 Request the leaderboard data from the server. More...
 
void SendIqGetProfile (const std::string &player)
 Request the profile data from the server. More...
 
void SendIqGameReport (const Script::Request &rq, JS::HandleValue data)
 Send game report containing numerous game properties to the server. More...
 
void SendIqRegisterGame (const Script::Request &rq, JS::HandleValue data)
 Send a request to register a game to the server. More...
 
void SendIqGetConnectionData (const std::string &jid, const std::string &password, const std::string &clientSalt, bool localIP)
 Request the Connection data (ip, port...) from the server. More...
 
void SendIqUnregisterGame ()
 Send a request to unregister a game to the server. More...
 
void SendIqChangeStateGame (const std::string &nbp, const std::string &players)
 Send a request to change the state of a registered game on the server. More...
 
void SendIqLobbyAuth (const std::string &to, const std::string &token)
 Send lobby authentication token. More...
 
void SetNick (const std::string &nick)
 Request MUC nick change, real change via mucRoomHandler. More...
 
std::string GetNick () const
 Get current MUC nickname. More...
 
std::string GetJID ()
 
std::string GetUsername () const
 Get the XMPP username. More...
 
void ChangePassword (const std::string &newPassword)
 Change password for authenticated user. More...
 
void kick (const std::string &nick, const std::string &reason)
 Kick a player from the current room. More...
 
void ban (const std::string &nick, const std::string &reason)
 Ban a player from the current room. More...
 
void SetPresence (const std::string &presence)
 Change the xmpp presence of the client. More...
 
const char * GetPresence (const std::string &nickname)
 Get the current xmpp presence of the given nick. More...
 
const char * GetRole (const std::string &nickname)
 Get the current xmpp role of the given nick. More...
 
std::wstring GetRating (const std::string &nickname)
 Get the most recent received rating of the given nick. More...
 
const std::wstring & GetSubject ()
 Get current subject. More...
 
JS::Value GUIGetPlayerList (const Script::Request &rq)
 Handle requests from the GUI for the list of players. More...
 
JS::Value GUIGetGameList (const Script::Request &rq)
 Handle requests from the GUI for the list of all active games. More...
 
JS::Value GUIGetBoardList (const Script::Request &rq)
 Handle requests from the GUI for leaderboard data. More...
 
JS::Value GUIGetProfile (const Script::Request &rq)
 Handle requests from the GUI for profile data. More...
 
JS::Value GuiPollNewMessages (const Script::Interface &guiInterface)
 
JS::Value GuiPollHistoricMessages (const Script::Interface &guiInterface)
 
bool GuiPollHasPlayerListUpdate ()
 
void SendMUCMessage (const std::string &message)
 Send a standard MUC textual message. More...
 
void SendStunEndpointToHost (const std::string &ip, std::uint16_t port, const std::string &hostJID)
 
void AddBuddy (const std::string &nick)
 Add the given nickname to the buddies of the current user. More...
 
void RemoveBuddy (const std::string &nick)
 Remove the given nickname from the buddies of the current user. More...
 
bool IsBuddy (const std::string &nick) const
 Whether the given nickname is a buddy of the current user. More...
 
std::set< std::string > GetBuddies () const
 Get the nicknames of all buddies of the current user. More...
 

Private Attributes

const std::unique_ptr< Impl > m_Impl
 

Constructor & Destructor Documentation

◆ XmppClient()

XmppClient::XmppClient ( const Script::Interface *  scriptInterface,
const std::string &  username,
const std::string &  password,
const std::string &  room,
const std::string &  nick,
const int  historyRequestSize = 0,
bool  regOpt = false 
)

Construct the XMPP client.

Parameters
scriptInterface- Script::Interface to be used for storing GUI messages. Can be left blank for non-visual applications.
sUsernameUsername to login with of register.
sPasswordPassword to login with or register.
sRoomMUC room to join.
sNickNick to join with.
historyRequestSizeNumber of stanzas of room history to request.
regOptIf we are just registering or not.

◆ ~XmppClient()

XmppClient::~XmppClient ( )

Destroy the xmpp client.

Member Function Documentation

◆ AddBuddy()

void XmppClient::AddBuddy ( const std::string &  nick)

Add the given nickname to the buddies of the current user.

Parameters
nickThe nickname of a player in the lobby.

◆ ban()

void XmppClient::ban ( const std::string &  nick,
const std::string &  reason 
)

Ban a player from the current room.

Parameters
nickNickname to be banned
reasonReason the player was banned

◆ ChangePassword()

void XmppClient::ChangePassword ( const std::string &  newPassword)

Change password for authenticated user.

Parameters
newPasswordNew password

◆ connect()

void XmppClient::connect ( )

Network.

◆ disconnect()

void XmppClient::disconnect ( )

◆ GetBuddies()

std::set< std::string > XmppClient::GetBuddies ( ) const

Get the nicknames of all buddies of the current user.

Returns
The (lowercase) nicknames of the buddies in the lobby's roster

◆ GetJID()

std::string XmppClient::GetJID ( )

◆ GetNick()

std::string XmppClient::GetNick ( ) const

Get current MUC nickname.

◆ GetPresence()

const char * XmppClient::GetPresence ( const std::string &  nickname)

Get the current xmpp presence of the given nick.

◆ GetRating()

std::wstring XmppClient::GetRating ( const std::string &  nick)

Get the most recent received rating of the given nick.

Notice that this doesn't request a rating profile if it hasn't been received yet.

◆ GetRole()

const char * XmppClient::GetRole ( const std::string &  nickname)

Get the current xmpp role of the given nick.

◆ GetSubject()

const std::wstring & XmppClient::GetSubject ( )

Get current subject.

◆ GetUsername()

std::string XmppClient::GetUsername ( ) const

Get the XMPP username.

Returns
current XMPP username

◆ GUIGetBoardList()

JS::Value XmppClient::GUIGetBoardList ( const Script::Request &  rq)

Handle requests from the GUI for leaderboard data.

Returns
A JS array containing all known leaderboard data

◆ GUIGetGameList()

JS::Value XmppClient::GUIGetGameList ( const Script::Request &  rq)

Handle requests from the GUI for the list of all active games.

Returns
A JS array containing all known games

◆ GUIGetPlayerList()

JS::Value XmppClient::GUIGetPlayerList ( const Script::Request &  rq)

Handle requests from the GUI for the list of players.

Returns
A JS array containing all known players and their presences

◆ GUIGetProfile()

JS::Value XmppClient::GUIGetProfile ( const Script::Request &  rq)

Handle requests from the GUI for profile data.

Returns
A JS array containing the specific user's profile data

◆ GuiPollHasPlayerListUpdate()

bool XmppClient::GuiPollHasPlayerListUpdate ( )

◆ GuiPollHistoricMessages()

JS::Value XmppClient::GuiPollHistoricMessages ( const Script::Interface &  guiInterface)

◆ GuiPollNewMessages()

JS::Value XmppClient::GuiPollNewMessages ( const Script::Interface &  guiInterface)

◆ IsBuddy()

bool XmppClient::IsBuddy ( const std::string &  nick) const

Whether the given nickname is a buddy of the current user.

The buddies are stored in the XMPP roster of the connected lobby. Since a nickname only identifies a user within one lobby, this is meaningless without a connection and always returns false in that case.

Parameters
nickThe nickname to look up, compared case-insensitively

◆ isConnected()

bool XmppClient::isConnected ( )

◆ kick()

void XmppClient::kick ( const std::string &  nick,
const std::string &  reason 
)

Kick a player from the current room.

Parameters
nickNickname to be kicked
reasonReason the player was kicked

◆ recv()

void XmppClient::recv ( )

◆ RemoveBuddy()

void XmppClient::RemoveBuddy ( const std::string &  nick)

Remove the given nickname from the buddies of the current user.

Parameters
nickThe nickname of a player in the lobby.

◆ SendIqChangeStateGame()

void XmppClient::SendIqChangeStateGame ( const std::string &  nbp,
const std::string &  players 
)

Send a request to change the state of a registered game on the server.

A game can either be in the 'running' or 'waiting' state - the server decides which - but we need to update the current players that are in-game so the server can make the calculation.

◆ SendIqGameReport()

void XmppClient::SendIqGameReport ( const Script::Request &  rq,
JS::HandleValue  data 
)

Send game report containing numerous game properties to the server.

Parameters
dataA JS array of game statistics

◆ SendIqGetBoardList()

void XmppClient::SendIqGetBoardList ( )

Request the leaderboard data from the server.

◆ SendIqGetConnectionData()

void XmppClient::SendIqGetConnectionData ( const std::string &  jid,
const std::string &  password,
const std::string &  clientSalt,
bool  localIP 
)

Request the Connection data (ip, port...) from the server.

◆ SendIqGetProfile()

void XmppClient::SendIqGetProfile ( const std::string &  player)

Request the profile data from the server.

◆ SendIqLobbyAuth()

void XmppClient::SendIqLobbyAuth ( const std::string &  to,
const std::string &  token 
)

Send lobby authentication token.

◆ SendIqRegisterGame()

void XmppClient::SendIqRegisterGame ( const Script::Request &  rq,
JS::HandleValue  data 
)

Send a request to register a game to the server.

Parameters
dataA JS array of game attributes

◆ SendIqUnregisterGame()

void XmppClient::SendIqUnregisterGame ( )

Send a request to unregister a game to the server.

◆ SendMUCMessage()

void XmppClient::SendMUCMessage ( const std::string &  message)

Send a standard MUC textual message.

◆ SendStunEndpointToHost()

void XmppClient::SendStunEndpointToHost ( const std::string &  ip,
std::uint16_t  port,
const std::string &  hostJID 
)

◆ SetNick()

void XmppClient::SetNick ( const std::string &  nick)

Request MUC nick change, real change via mucRoomHandler.

Parameters
nickDesired MUC nickname

◆ SetPresence()

void XmppClient::SetPresence ( const std::string &  presence)

Change the xmpp presence of the client.

Parameters
presenceA string containing the desired presence

Member Data Documentation

◆ m_Impl

const std::unique_ptr<Impl> XmppClient::m_Impl
private

The documentation for this class was generated from the following files: