Pyrogenesis
trunk
|
#include <XmppClient.h>
Classes | |
struct | SPlayer |
Public Member Functions | |
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) | |
Construct the XMPP client. More... | |
virtual | ~XmppClient () |
Destroy the xmpp client. More... | |
void | TraceMember (JSTracer *trc) |
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 ScriptRequest &rq, JS::HandleValue data) |
Send game report containing numerous game properties to the server. More... | |
void | SendIqRegisterGame (const ScriptRequest &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 nick change, real change via mucRoomHandler. More... | |
std::string | GetNick () const |
Get current nickname. More... | |
std::string | GetJID () const |
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 ScriptRequest &rq) |
Handle requests from the GUI for the list of players. More... | |
JS::Value | GUIGetGameList (const ScriptRequest &rq) |
Handle requests from the GUI for the list of all active games. More... | |
JS::Value | GUIGetBoardList (const ScriptRequest &rq) |
Handle requests from the GUI for leaderboard data. More... | |
JS::Value | GUIGetProfile (const ScriptRequest &rq) |
Handle requests from the GUI for profile data. More... | |
void | SendStunEndpointToHost (const std::string &ip, u16 port, const std::string &hostJID) |
JS::Value | GuiPollNewMessages (const ScriptInterface &guiInterface) |
JS::Value | GuiPollHistoricMessages (const ScriptInterface &guiInterface) |
bool | GuiPollHasPlayerListUpdate () |
void | SendMUCMessage (const std::string &message) |
Send a standard MUC textual message. More... | |
Public Member Functions inherited from IXmppClient | |
virtual | ~IXmppClient () |
Public Member Functions inherited from glooxwrapper::ConnectionListener | |
virtual | ~ConnectionListener () |
Public Member Functions inherited from glooxwrapper::MUCRoomHandler | |
virtual | ~MUCRoomHandler () |
Public Member Functions inherited from glooxwrapper::IqHandler | |
virtual | ~IqHandler () |
Public Member Functions inherited from glooxwrapper::RegistrationHandler | |
virtual | ~RegistrationHandler () |
virtual void | handleDataForm (const JID &from, const DataForm &form)=0 |
virtual void | handleOOB (const JID &from, const OOB &oob)=0 |
Public Member Functions inherited from glooxwrapper::MessageHandler | |
virtual | ~MessageHandler () |
virtual void | handleMessage (const Message &msg, MessageSession *session=0)=0 |
Public Member Functions inherited from glooxwrapper::Jingle::SessionHandler | |
virtual | ~SessionHandler () |
Static Public Member Functions | |
static void | Trace (JSTracer *trc, void *data) |
static const char * | GetPresenceString (const gloox::Presence::PresenceType presenceType) |
Convert gloox values to string or time. More... | |
static const char * | GetRoleString (const gloox::MUCRoomRole role) |
Convert a gloox role type to an untranslated string literal to be used as an identifier by the scripts. More... | |
static std::string | StanzaErrorToString (gloox::StanzaError err) |
Convert a gloox stanza error type to string. More... | |
static std::string | RegistrationResultToString (gloox::RegistrationResult res) |
Convert a gloox registration result enum to string Keep in sync with Gloox documentation. More... | |
static std::string | ConnectionErrorToString (gloox::ConnectionError err) |
Convert a gloox connection error enum to string Keep in sync with Gloox documentation. More... | |
static std::string | CertificateErrorToString (gloox::CertStatus status) |
Translates a gloox certificate error codes, i.e. More... | |
static std::time_t | ComputeTimestamp (const glooxwrapper::Message &msg) |
Parse and return the timestamp of a historic chat message and return the current time for new chat messages. More... | |
Static Public Member Functions inherited from IXmppClient | |
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) |
Protected Member Functions | |
virtual void | handleMUCParticipantPresence (glooxwrapper::MUCRoom &room, const glooxwrapper::MUCRoomParticipant, const glooxwrapper::Presence &) |
Update local data when a user changes presence. More... | |
virtual void | handleMUCError (glooxwrapper::MUCRoom &room, gloox::StanzaError) |
Handle MUC room errors. More... | |
virtual void | handleMUCMessage (glooxwrapper::MUCRoom &room, const glooxwrapper::Message &msg, bool priv) |
Handle a room message. More... | |
virtual void | handleMUCSubject (glooxwrapper::MUCRoom &room, const glooxwrapper::string &nick, const glooxwrapper::string &subject) |
Update local cache when subject changes. More... | |
virtual void | handleLog (gloox::LogLevel level, gloox::LogArea area, const std::string &message) |
Log (debug) Handler. More... | |
virtual void | onConnect () |
Handle connection. More... | |
virtual void | onDisconnect (gloox::ConnectionError e) |
Handle disconnection. More... | |
virtual bool | onTLSConnect (const glooxwrapper::CertInfo &info) |
Handle TLS connection. More... | |
virtual bool | handleIq (const glooxwrapper::IQ &iq) |
Handle portions of messages containing custom stanza extensions. More... | |
virtual void | handleIqID (const glooxwrapper::IQ &, int) |
virtual void | handleRegistrationFields (const glooxwrapper::JID &, int fields, glooxwrapper::string instructions) |
virtual void | handleRegistrationResult (const glooxwrapper::JID &, gloox::RegistrationResult result) |
virtual void | handleAlreadyRegistered (const glooxwrapper::JID &) |
virtual void | handleDataForm (const glooxwrapper::JID &, const glooxwrapper::DataForm &) |
virtual void | handleOOB (const glooxwrapper::JID &, const glooxwrapper::OOB &oob) |
virtual void | handleMessage (const glooxwrapper::Message &msg, glooxwrapper::MessageSession *session) |
Handle a private message. More... | |
virtual void | handleSessionAction (gloox::Jingle::Action action, glooxwrapper::Jingle::Session &session, const glooxwrapper::Jingle::Session::Jingle &jingle) |
virtual void | handleSessionInitiation (glooxwrapper::Jingle::Session &session, const glooxwrapper::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) |
Private Types | |
using | PlayerMap = std::map< glooxwrapper::string, SPlayer > |
Private Member Functions | |
NONCOPYABLE (XmppClient) | |
Private Attributes | |
glooxwrapper::Client * | m_client |
glooxwrapper::MUCRoom * | m_mucRoom |
glooxwrapper::Registration * | m_registration |
glooxwrapper::SessionManager * | m_sessionManager |
std::string | m_username |
std::string | m_password |
std::string | m_server |
std::string | m_room |
std::string | m_nick |
std::string | m_xpartamuppId |
std::string | m_echelonId |
std::string | m_connectionDataJid |
std::string | m_connectionDataIqId |
gloox::CertStatus | m_certStatus |
bool | m_initialLoadComplete |
bool | m_isConnected |
PlayerMap | m_PlayerMap |
Map of players. More... | |
bool | m_PlayerMapUpdate |
Whether or not the playermap has changed since the last time the GUI checked. More... | |
std::vector< const glooxwrapper::Tag * > | m_GameList |
List of games. More... | |
std::vector< const glooxwrapper::Tag * > | m_BoardList |
List of rankings. More... | |
std::vector< const glooxwrapper::Tag * > | m_Profile |
Profile data. More... | |
const ScriptInterface * | m_ScriptInterface |
ScriptInterface to root the values. More... | |
std::deque< JS::Heap< JS::Value > > | m_GuiMessageQueue |
Queue of messages for the GUI. More... | |
std::vector< JS::Heap< JS::Value > > | m_HistoricGuiMessages |
Cache of all GUI messages received since the login. More... | |
std::wstring | m_Subject |
Current room subject/topic. More... | |
|
private |
XmppClient::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 |
||
) |
Construct the XMPP client.
scriptInterface | - ScriptInterface to be used for storing GUI messages. Can be left blank for non-visual applications. |
sUsername | Username to login with of register. |
sPassword | Password to login with or register. |
sRoom | MUC room to join. |
sNick | Nick to join with. |
historyRequestSize | Number of stanzas of room history to request. |
regOpt | If we are just registering or not. |
|
virtual |
Destroy the xmpp client.
|
virtual |
Ban a player from the current room.
nick | Nickname to be banned |
reason | Reason the player was banned |
Implements IXmppClient.
|
static |
Translates a gloox certificate error codes, i.e.
gloox certificate statuses except CertOk. Keep in sync with specifications.
|
static |
Parse and return the timestamp of a historic chat message and return the current time for new chat messages.
Historic chat messages are implement as DelayedDelivers as specified in XEP-0203. Hence, their timestamp MUST be in UTC and conform to the DateTime format XEP-0082.
|
virtual |
Network.
Implements IXmppClient.
|
static |
Convert a gloox connection error enum to string Keep in sync with Gloox documentation.
err | Error to be converted |
|
protected |
|
virtual |
Implements IXmppClient.
|
virtual |
Implements IXmppClient.
|
virtual |
Get current nickname.
Implements IXmppClient.
|
virtual |
Get the current xmpp presence of the given nick.
Implements IXmppClient.
|
static |
Convert gloox values to string or time.
Convert a gloox presence type to an untranslated string literal to be used as an identifier by the scripts.
|
virtual |
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.
Implements IXmppClient.
|
virtual |
Get the current xmpp role of the given nick.
Implements IXmppClient.
|
static |
Convert a gloox role type to an untranslated string literal to be used as an identifier by the scripts.
|
virtual |
Get current subject.
Implements IXmppClient.
|
virtual |
Handle requests from the GUI for leaderboard data.
Implements IXmppClient.
|
virtual |
Handle requests from the GUI for the list of all active games.
Implements IXmppClient.
|
virtual |
Handle requests from the GUI for the list of players.
Implements IXmppClient.
|
virtual |
Handle requests from the GUI for profile data.
Implements IXmppClient.
|
virtual |
Implements IXmppClient.
|
virtual |
Implements IXmppClient.
|
virtual |
Implements IXmppClient.
|
protectedvirtual |
Implements glooxwrapper::RegistrationHandler.
|
protectedvirtual |
|
protectedvirtual |
Handle portions of messages containing custom stanza extensions.
Implements glooxwrapper::IqHandler.
|
inlineprotectedvirtual |
Implements glooxwrapper::IqHandler.
|
protectedvirtual |
Log (debug) Handler.
|
protectedvirtual |
Handle a private message.
|
protectedvirtual |
Handle MUC room errors.
Implements glooxwrapper::MUCRoomHandler.
|
protectedvirtual |
Handle a room message.
Implements glooxwrapper::MUCRoomHandler.
|
protectedvirtual |
Update local data when a user changes presence.
Implements glooxwrapper::MUCRoomHandler.
|
protectedvirtual |
Update local cache when subject changes.
Implements glooxwrapper::MUCRoomHandler.
|
protectedvirtual |
|
protectedvirtual |
Implements glooxwrapper::RegistrationHandler.
|
protectedvirtual |
Implements glooxwrapper::RegistrationHandler.
|
protectedvirtual |
Implements glooxwrapper::Jingle::SessionHandler.
|
protectedvirtual |
|
virtual |
Implements IXmppClient.
|
virtual |
Kick a player from the current room.
nick | Nickname to be kicked |
reason | Reason the player was kicked |
Implements IXmppClient.
|
private |
|
protectedvirtual |
Handle connection.
Implements glooxwrapper::ConnectionListener.
|
protectedvirtual |
Handle disconnection.
Implements glooxwrapper::ConnectionListener.
|
protectedvirtual |
Handle TLS connection.
Implements glooxwrapper::ConnectionListener.
|
virtual |
Implements IXmppClient.
|
static |
Convert a gloox registration result enum to string Keep in sync with Gloox documentation.
err | Enum to be converted |
|
virtual |
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.
Implements IXmppClient.
|
virtual |
Send game report containing numerous game properties to the server.
data | A JS array of game statistics |
Implements IXmppClient.
|
virtual |
Request the leaderboard data from the server.
Implements IXmppClient.
|
virtual |
Request the Connection data (ip, port...) from the server.
Implements IXmppClient.
|
virtual |
Request the profile data from the server.
Implements IXmppClient.
|
virtual |
Send lobby authentication token.
Implements IXmppClient.
|
virtual |
Send a request to register a game to the server.
data | A JS array of game attributes |
Implements IXmppClient.
|
virtual |
Send a request to unregister a game to the server.
Implements IXmppClient.
|
virtual |
Send a standard MUC textual message.
Implements IXmppClient.
|
virtual |
Implements IXmppClient.
|
virtual |
Request nick change, real change via mucRoomHandler.
nick | Desired nickname |
Implements IXmppClient.
|
virtual |
Change the xmpp presence of the client.
presence | A string containing the desired presence |
Implements IXmppClient.
|
static |
Convert a gloox stanza error type to string.
Keep in sync with Gloox documentation
err | Error to be converted |
|
inlinestatic |
void XmppClient::TraceMember | ( | JSTracer * | trc | ) |
|
private |
List of rankings.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
List of games.
|
private |
Queue of messages for the GUI.
|
private |
Cache of all GUI messages received since the login.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Map of players.
|
private |
Whether or not the playermap has changed since the last time the GUI checked.
|
private |
Profile data.
|
private |
|
private |
|
private |
ScriptInterface to root the values.
|
private |
|
private |
|
private |
Current room subject/topic.
|
private |
|
private |