Changeset View
Changeset View
Standalone View
Standalone View
source/lobby/XmppClient.cpp
Show First 20 Lines • Show All 739 Lines • ▼ Show 20 Lines | void XmppClient::SendMUCMessage(const std::string& message) | ||||
m_mucRoom->send(message); | m_mucRoom->send(message); | ||||
} | } | ||||
/** | /** | ||||
* Handle a room message. | * Handle a room message. | ||||
*/ | */ | ||||
void XmppClient::handleMUCMessage(glooxwrapper::MUCRoom& UNUSED(room), const glooxwrapper::Message& msg, bool priv) | void XmppClient::handleMUCMessage(glooxwrapper::MUCRoom& UNUSED(room), const glooxwrapper::Message& msg, bool priv) | ||||
{ | { | ||||
DbgXMPP(msg.from().resource() << " said " << msg.body()); | DbgXMPP( | ||||
"handleMUCMessage " | |||||
"Subtype: " << MessageSubtypeToString(msg.subtype()) << ", " | |||||
"From: " << msg.from().resource() << ", " | |||||
"Subject: " << msg.subject() << ", " | |||||
"Body: " << msg.body() << ", " | |||||
"Private: " << (priv ? "true" : "false")); | |||||
CreateGUIMessage( | CreateGUIMessage( | ||||
"chat", | "chat", | ||||
priv ? "private-message" : "room-message", | "muc-message", | ||||
ComputeTimestamp(msg), | ComputeTimestamp(msg), | ||||
"subtype", msg.subtype(), | |||||
"private", priv, | |||||
"from", msg.from().resource(), | "from", msg.from().resource(), | ||||
"text", msg.body()); | "subject", msg.subject(), | ||||
"body", msg.body()); | |||||
} | } | ||||
/** | /** | ||||
* Handle a private message. | * Handle a message sent to the user. | ||||
*/ | */ | ||||
void XmppClient::handleMessage(const glooxwrapper::Message& msg, glooxwrapper::MessageSession*) | void XmppClient::handleMessage(const glooxwrapper::Message& msg, glooxwrapper::MessageSession*) | ||||
{ | { | ||||
DbgXMPP("type " << msg.subtype() << ", subject " << msg.subject() | DbgXMPP( | ||||
<< ", message " << msg.body() << ", thread id " << msg.thread()); | "handleMessage " | ||||
"Subtype: " << MessageSubtypeToString(msg.subtype()) << ", " | |||||
"From: " << msg.from().username() << ", " | |||||
"Subject:" << msg.subject() << ", " | |||||
"Body:" << msg.body()); | |||||
CreateGUIMessage( | CreateGUIMessage( | ||||
"chat", | "chat", | ||||
"private-message", | "message", | ||||
ComputeTimestamp(msg), | ComputeTimestamp(msg), | ||||
"from", msg.from().resource(), | "subtype", msg.subtype(), | ||||
"text", msg.body()); | "from", msg.from().username(), | ||||
"subject", msg.subject(), | |||||
"body", msg.body()); | |||||
} | } | ||||
/** | /** | ||||
* Handle portions of messages containing custom stanza extensions. | * Handle portions of messages containing custom stanza extensions. | ||||
*/ | */ | ||||
bool XmppClient::handleIq(const glooxwrapper::IQ& iq) | bool XmppClient::handleIq(const glooxwrapper::IQ& iq) | ||||
{ | { | ||||
DbgXMPP("handleIq [" << tag_xml(iq) << "]"); | DbgXMPP("handleIq [" << tag_xml(iq) << "]"); | ||||
▲ Show 20 Lines • Show All 199 Lines • ▼ Show 20 Lines | void XmppClient::handleMUCParticipantPresence(glooxwrapper::MUCRoom& UNUSED(room), const glooxwrapper::MUCRoomParticipant participant, const glooxwrapper::Presence& presence) | ||||
m_PlayerMapUpdate = true; | m_PlayerMapUpdate = true; | ||||
} | } | ||||
/** | /** | ||||
* Update local cache when subject changes. | * Update local cache when subject changes. | ||||
*/ | */ | ||||
void XmppClient::handleMUCSubject(glooxwrapper::MUCRoom& UNUSED(room), const glooxwrapper::string& nick, const glooxwrapper::string& subject) | void XmppClient::handleMUCSubject(glooxwrapper::MUCRoom& UNUSED(room), const glooxwrapper::string& nick, const glooxwrapper::string& subject) | ||||
{ | { | ||||
DbgXMPP("Lobby subject changed to " << subject); | |||||
m_Subject = wstring_from_utf8(subject.to_string()); | m_Subject = wstring_from_utf8(subject.to_string()); | ||||
CreateGUIMessage( | CreateGUIMessage( | ||||
"chat", | "chat", | ||||
"subject", | "subject", | ||||
std::time(nullptr), | std::time(nullptr), | ||||
"nick", nick, | "nick", nick, | ||||
"subject", m_Subject); | "subject", m_Subject); | ||||
▲ Show 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | #define DEBUG_CASE(X, Y) case gloox::X: return g_L10n.Translate("Error") + " (" + Y + ")" | ||||
DEBUG_CASE(RegistrationNotAllowed, "Server does not permit password changes"); | DEBUG_CASE(RegistrationNotAllowed, "Server does not permit password changes"); | ||||
default: | default: | ||||
return ""; | return ""; | ||||
} | } | ||||
#undef DEBUG_CASE | #undef DEBUG_CASE | ||||
#undef CASE | #undef CASE | ||||
} | } | ||||
const char* XmppClient::MessageSubtypeToString(gloox::Message::MessageType messageType) | |||||
{ | |||||
#define CASE(X) case gloox::Message::MessageType::X: return #X; | |||||
switch (messageType) | |||||
{ | |||||
CASE(Chat) | |||||
CASE(Error) | |||||
CASE(Groupchat) | |||||
CASE(Headline) | |||||
CASE(Normal) | |||||
default: | |||||
return "invalid"; | |||||
Stan: Invalid Message ? | |||||
elexisAuthorUnsubmitted Done Inline ActionsThis is not a string to be read by humans but a string identifier for JS (otherwise the strings above would be highly broken) elexis: This is not a string to be read by humans but a string identifier for JS (otherwise the strings… | |||||
} | |||||
#undef CASE | |||||
} | |||||
void XmppClient::SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJIDStr) | void XmppClient::SendStunEndpointToHost(const StunClient::StunEndpoint& stunEndpoint, const std::string& hostJIDStr) | ||||
{ | { | ||||
DbgXMPP("SendStunEndpointToHost " << hostJIDStr); | DbgXMPP("SendStunEndpointToHost " << hostJIDStr); | ||||
char ipStr[256] = "(error)"; | char ipStr[256] = "(error)"; | ||||
ENetAddress addr; | ENetAddress addr; | ||||
addr.host = ntohl(stunEndpoint.ip); | addr.host = ntohl(stunEndpoint.ip); | ||||
enet_address_get_host_ip(&addr, ipStr, ARRAY_SIZE(ipStr)); | enet_address_get_host_ip(&addr, ipStr, ARRAY_SIZE(ipStr)); | ||||
Show All 30 Lines |
Wildfire Games · Phabricator
Invalid Message ?