Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/lobby/XmppClient.h
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | public: | ||||
void SendIqUnregisterGame(); | void SendIqUnregisterGame(); | ||||
void SendIqChangeStateGame(const std::string& nbp, const std::string& players); | void SendIqChangeStateGame(const std::string& nbp, const std::string& players); | ||||
void SendIqLobbyAuth(const std::string& to, const std::string& token); | void SendIqLobbyAuth(const std::string& to, const std::string& token); | ||||
void SetNick(const std::string& nick); | void SetNick(const std::string& nick); | ||||
void GetNick(std::string& nick); | void GetNick(std::string& nick); | ||||
void kick(const std::string& nick, const std::string& reason); | void kick(const std::string& nick, const std::string& reason); | ||||
void ban(const std::string& nick, const std::string& reason); | void ban(const std::string& nick, const std::string& reason); | ||||
void SetPresence(const std::string& presence); | void SetPresence(const std::string& presence); | ||||
void GetPresence(const std::string& nickname, std::string& presence); | const char* GetPresence(const std::string& nickname); | ||||
void GetRole(const std::string& nickname, std::string& role); | const char* GetRole(const std::string& nickname); | ||||
void GetSubject(std::string& subject); | const std::wstring& GetSubject(); | ||||
void GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | void GUIGetPlayerList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | ||||
void GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | void GUIGetGameList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | ||||
void GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | void GUIGetBoardList(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | ||||
void GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | void GUIGetProfile(const ScriptInterface& scriptInterface, JS::MutableHandleValue ret); | ||||
void SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJID); | void SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJID); | ||||
/** | |||||
* Convert gloox values to string or time. | |||||
*/ | |||||
static const char* GetPresenceString(const gloox::Presence::PresenceType presenceType); | |||||
static const char* GetRoleString(const gloox::MUCRoomRole role); | |||||
static std::string StanzaErrorToString(gloox::StanzaError err); | |||||
static std::string RegistrationResultToString(gloox::RegistrationResult res); | |||||
static std::string ConnectionErrorToString(gloox::ConnectionError err); | |||||
static std::string CertificateErrorToString(gloox::CertStatus status); | |||||
static std::time_t ComputeTimestamp(const glooxwrapper::Message& msg); | |||||
protected: | protected: | ||||
/* Xmpp handlers */ | /* Xmpp handlers */ | ||||
/* MUC handlers */ | /* MUC handlers */ | ||||
virtual void handleMUCParticipantPresence(glooxwrapper::MUCRoom*, const glooxwrapper::MUCRoomParticipant, const glooxwrapper::Presence&); | virtual void handleMUCParticipantPresence(glooxwrapper::MUCRoom*, const glooxwrapper::MUCRoomParticipant, const glooxwrapper::Presence&); | ||||
virtual void handleMUCError(glooxwrapper::MUCRoom*, gloox::StanzaError); | virtual void handleMUCError(glooxwrapper::MUCRoom*, gloox::StanzaError); | ||||
virtual void handleMUCMessage(glooxwrapper::MUCRoom* room, const glooxwrapper::Message& msg, bool priv); | virtual void handleMUCMessage(glooxwrapper::MUCRoom* room, const glooxwrapper::Message& msg, bool priv); | ||||
virtual void handleMUCSubject(glooxwrapper::MUCRoom*, const glooxwrapper::string& nick, const glooxwrapper::string& subject); | virtual void handleMUCSubject(glooxwrapper::MUCRoom*, const glooxwrapper::string& nick, const glooxwrapper::string& subject); | ||||
/* MUC handlers not supported by glooxwrapper */ | /* MUC handlers not supported by glooxwrapper */ | ||||
Show All 23 Lines | protected: | ||||
/* Message Handler */ | /* Message Handler */ | ||||
virtual void handleMessage(const glooxwrapper::Message& msg, glooxwrapper::MessageSession* session); | virtual void handleMessage(const glooxwrapper::Message& msg, glooxwrapper::MessageSession* session); | ||||
/* Session Handler */ | /* Session Handler */ | ||||
virtual void handleSessionAction(gloox::Jingle::Action action, glooxwrapper::Jingle::Session& session, const glooxwrapper::Jingle::Session::Jingle& jingle); | 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); | virtual void handleSessionInitiation(glooxwrapper::Jingle::Session& session, const glooxwrapper::Jingle::Session::Jingle& jingle); | ||||
// Helpers | |||||
void GetPresenceString(const gloox::Presence::PresenceType p, std::string& presence) const; | |||||
void GetRoleString(const gloox::MUCRoomRole r, std::string& role) const; | |||||
std::string StanzaErrorToString(gloox::StanzaError err) const; | |||||
std::string ConnectionErrorToString(gloox::ConnectionError err) const; | |||||
std::string CertificateErrorToString(gloox::CertStatus status) const; | |||||
std::string RegistrationResultToString(gloox::RegistrationResult res) const; | |||||
std::time_t ComputeTimestamp(const glooxwrapper::Message& msg) const; | |||||
public: | public: | ||||
JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface); | JS::Value GuiPollNewMessage(const ScriptInterface& scriptInterface); | ||||
JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface); | JS::Value GuiPollHistoricMessages(const ScriptInterface& scriptInterface); | ||||
bool GuiPollHasPlayerListUpdate(); | bool GuiPollHasPlayerListUpdate(); | ||||
void SendMUCMessage(const std::string& message); | void SendMUCMessage(const std::string& message); | ||||
protected: | protected: | ||||
template<typename... Args> | template<typename... Args> | ||||
void CreateGUIMessage( | void CreateGUIMessage( | ||||
const std::string& type, | const std::string& type, | ||||
const std::string& level, | const std::string& level, | ||||
const std::time_t time, | const std::time_t time, | ||||
Args const&... args); | Args const&... args); | ||||
private: | private: | ||||
struct SPlayer { | |||||
SPlayer(const gloox::Presence::PresenceType presence, const gloox::MUCRoomRole role, const glooxwrapper::string& rating) | |||||
: m_Presence(presence), m_Role(role), m_Rating(rating) | |||||
{ | |||||
} | |||||
gloox::Presence::PresenceType m_Presence; | |||||
gloox::MUCRoomRole m_Role; | |||||
glooxwrapper::string m_Rating; | |||||
}; | |||||
using PlayerMap = std::map<glooxwrapper::string, SPlayer>; | |||||
/// Map of players | /// Map of players | ||||
std::map<std::string, std::vector<std::string> > m_PlayerMap; | PlayerMap m_PlayerMap; | ||||
/// Whether or not the playermap has changed since the last time the GUI checked. | /// Whether or not the playermap has changed since the last time the GUI checked. | ||||
bool m_PlayerMapUpdate; | bool m_PlayerMapUpdate; | ||||
/// List of games | /// List of games | ||||
std::vector<const glooxwrapper::Tag*> m_GameList; | std::vector<const glooxwrapper::Tag*> m_GameList; | ||||
/// List of rankings | /// List of rankings | ||||
std::vector<const glooxwrapper::Tag*> m_BoardList; | std::vector<const glooxwrapper::Tag*> m_BoardList; | ||||
/// Profile data | /// Profile data | ||||
std::vector<const glooxwrapper::Tag*> m_Profile; | std::vector<const glooxwrapper::Tag*> m_Profile; | ||||
/// ScriptInterface to root the values | /// ScriptInterface to root the values | ||||
const ScriptInterface* m_ScriptInterface; | const ScriptInterface* m_ScriptInterface; | ||||
/// Queue of messages for the GUI | /// Queue of messages for the GUI | ||||
std::deque<JS::Heap<JS::Value> > m_GuiMessageQueue; | std::deque<JS::Heap<JS::Value> > m_GuiMessageQueue; | ||||
/// Cache of all GUI messages received since the login | /// Cache of all GUI messages received since the login | ||||
std::vector<JS::Heap<JS::Value> > m_HistoricGuiMessages; | std::vector<JS::Heap<JS::Value> > m_HistoricGuiMessages; | ||||
/// Current room subject/topic. | /// Current room subject/topic. | ||||
std::string m_Subject; | std::wstring m_Subject; | ||||
}; | }; | ||||
#endif // XMPPCLIENT_H | #endif // XMPPCLIENT_H |
Wildfire Games · Phabricator