Pyrogenesis
trunk
|
#include <XmppClient.h>
Classes | |
struct | GUIMessage |
Public Member Functions | |
XmppClient (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 | connect () |
Network. More... | |
void | disconnect () |
void | recv () |
void | SendIqGetGameList () |
Request a listing of active games from the server. More... | |
void | SendIqGetBoardList () |
Request the leaderboard data from the server. More... | |
void | SendIqGetRatingList () |
Request the rating data from the server. More... | |
void | SendIqGetProfile (const std::string &player) |
Request the profile data from the server. More... | |
void | SendIqGameReport (ScriptInterface &scriptInterface, JS::HandleValue data) |
Send game report containing numerous game properties to the server. More... | |
void | SendIqRegisterGame (ScriptInterface &scriptInterface, JS::HandleValue data) |
Send a request to register a game to 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 | SetNick (const std::string &nick) |
Request nick change, real change via mucRoomHandler. More... | |
void | GetNick (std::string &nick) |
Get current nickname. 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... | |
void | GetPresence (const std::string &nickname, std::string &presence) |
Get the current xmpp presence of the given nick. More... | |
void | GetRole (const std::string &nickname, std::string &role) |
Get the current xmpp role of the given nick. More... | |
void | GetSubject (std::string &subject) |
Get current subject. More... | |
void | GUIGetPlayerList (ScriptInterface &scriptInterface, JS::MutableHandleValue ret) |
Handle requests from the GUI for the list of players. More... | |
void | GUIGetGameList (ScriptInterface &scriptInterface, JS::MutableHandleValue ret) |
Handle requests from the GUI for the list of all active games. More... | |
void | GUIGetBoardList (ScriptInterface &scriptInterface, JS::MutableHandleValue ret) |
Handle requests from the GUI for leaderboard data. More... | |
void | GUIGetProfile (ScriptInterface &scriptInterface, JS::MutableHandleValue ret) |
Handle requests from the GUI for profile data. More... | |
ScriptInterface & | GetScriptInterface () |
void | GuiPollMessage (ScriptInterface &scriptInterface, JS::MutableHandleValue ret) |
Send GUI message queue when queried. More... | |
void | SendMUCMessage (const std::string &message) |
Send a standard MUC textual message. More... | |
void | ClearPresenceUpdates () |
Clears all presence updates from the message queue. More... | |
int | GetMucMessageCount () |
Used in order to update the GUI only once when multiple updates are queued. 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 |
Protected Member Functions | |
virtual void | handleMUCParticipantPresence (glooxwrapper::MUCRoom *, const glooxwrapper::MUCRoomParticipant, const glooxwrapper::Presence &) |
Update local data when a user changes presence. More... | |
virtual void | handleMUCError (glooxwrapper::MUCRoom *, 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 *, 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... | |
void | GetPresenceString (const gloox::Presence::PresenceType p, std::string &presence) const |
Convert a gloox presence type to string. More... | |
void | GetRoleString (const gloox::MUCRoomRole r, std::string &role) const |
Convert a gloox role type to string. More... | |
std::string | StanzaErrorToString (gloox::StanzaError err) const |
Convert a gloox stanza error type to string. More... | |
std::string | ConnectionErrorToString (gloox::ConnectionError err) const |
Convert a gloox connection error enum to string Keep in sync with Gloox documentation. More... | |
std::string | RegistrationResultToString (gloox::RegistrationResult res) const |
Convert a gloox registration result enum to string Keep in sync with Gloox documentation. More... | |
void | PushGuiMessage (XmppClient::GUIMessage message) |
Push a message onto the GUI queue. More... | |
void | CreateGUIMessage (const std::string &type, const std::string &level, const std::string &text="", const std::string &data="") |
Create a new detail message for the GUI. More... | |
Private Member Functions | |
NONCOPYABLE (XmppClient) | |
Private Attributes | |
glooxwrapper::Client * | m_client |
glooxwrapper::MUCRoom * | m_mucRoom |
glooxwrapper::Registration * | m_registration |
std::string | m_username |
std::string | m_password |
std::string | m_nick |
std::string | m_xpartamuppId |
bool | m_initialLoadComplete |
std::map< std::string, std::vector< std::string > > | m_PlayerMap |
Map of players. 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... | |
std::deque< GUIMessage > | m_GuiMessageQueue |
Queue of messages for the GUI. More... | |
std::string | m_Subject |
Current room subject/topic. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from IXmppClient | |
static IXmppClient * | create (const std::string &sUsername, const std::string &sPassword, const std::string &sRoom, const std::string &sNick, const int historyRequestSize=0, bool regOpt=false) |
XmppClient::XmppClient | ( | 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.
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.
|
virtual |
Clears all presence updates from the message queue.
Used when rejoining the lobby, since we don't need to handle past presence changes.
Implements IXmppClient.
|
virtual |
Network.
Implements IXmppClient.
|
protected |
Convert a gloox connection error enum to string Keep in sync with Gloox documentation.
err | Error to be converted |
|
protected |
Create a new detail message for the GUI.
type | General message type |
level | Detailed message type |
text | Body of the message |
data | Optional field, used for auxiliary data |
|
virtual |
Implements IXmppClient.
|
virtual |
Used in order to update the GUI only once when multiple updates are queued.
Implements IXmppClient.
|
virtual |
|
virtual |
Get the current xmpp presence of the given nick.
nick | Nickname to look up presence for |
presence | Variable to store the presence in |
Implements IXmppClient.
|
protected |
Convert a gloox presence type to string.
p | Presence to be converted |
presence | Variable to store the converted presence string in |
|
virtual |
Get the current xmpp role of the given nick.
nick | Nickname to look up presence for |
role | Variable to store the role in |
Implements IXmppClient.
|
protected |
Convert a gloox role type to string.
p | Role to be converted |
presence | Variable to store the converted role string in |
ScriptInterface& XmppClient::GetScriptInterface | ( | ) |
|
virtual |
|
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 |
Send GUI message queue when queried.
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.
|
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.
|
protected |
Push a message onto the GUI queue.
message | Message to add to the queue |
|
virtual |
Implements IXmppClient.
|
protected |
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 a listing of active games from the server.
Implements IXmppClient.
|
virtual |
Request the profile data from the server.
Implements IXmppClient.
|
virtual |
Request the rating data from the server.
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 |
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.
|
protected |
Convert a gloox stanza error type to string.
Keep in sync with Gloox documentation
err | Error to be converted |
|
private |
List of rankings.
|
private |
|
private |
List of games.
|
private |
Queue of messages for the GUI.
|
private |
|
private |
|
private |
|
private |
|
private |
Map of players.
|
private |
Profile data.
|
private |
|
private |
Current room subject/topic.
|
private |
|
private |