summaryrefslogtreecommitdiff
path: root/src/xmpp/xmpp_component.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp/xmpp_component.cpp')
-rw-r--r--src/xmpp/xmpp_component.cpp52
1 files changed, 19 insertions, 33 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 1e8f9e0..1aa98b0 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -37,7 +37,7 @@ static std::set<std::string> kickable_errors{
};
XmppComponent::XmppComponent(std::shared_ptr<Poller> poller, const std::string& hostname, const std::string& secret):
- SocketHandler(poller),
+ TCPSocketHandler(poller),
ever_auth(false),
last_auth(false),
served_hostname(hostname),
@@ -108,9 +108,16 @@ void XmppComponent::on_connected()
this->send_pending_data();
}
-void XmppComponent::on_connection_close()
+void XmppComponent::on_connection_close(const std::string& error)
{
- log_info("XMPP server closed connection");
+ if (error.empty())
+ {
+ log_info("XMPP server closed connection");
+ }
+ else
+ {
+ log_info("XMPP server closed connection: " << error);
+ }
}
void XmppComponent::parse_in_buffer(const size_t size)
@@ -904,41 +911,18 @@ void XmppComponent::kick_user(const std::string& muc_name,
this->send_stanza(presence);
}
-void XmppComponent::send_nickname_conflict_error(const std::string& muc_name,
- const std::string& nickname,
- const std::string& jid_to)
-{
- Stanza presence("presence");
- presence["from"] = muc_name + "@" + this->served_hostname + "/" + nickname;
- presence["to"] = jid_to;
- XmlNode x("x");
- x["xmlns"] = MUC_NS;
- x.close();
- presence.add_child(std::move(x));
- XmlNode error("error");
- error["by"] = muc_name + "@" + this->served_hostname;
- error["type"] = "cancel";
- error["code"] = "409";
- XmlNode conflict("conflict");
- conflict["xmlns"] = STANZA_NS;
- conflict.close();
- error.add_child(std::move(conflict));
- error.close();
- presence.add_child(std::move(error));
- presence.close();
- this->send_stanza(presence);
-}
-
void XmppComponent::send_presence_error(const std::string& muc_name,
- const std::string& nickname,
- const std::string& jid_to,
- const std::string& type,
- const std::string& condition,
- const std::string&)
+ const std::string& nickname,
+ const std::string& jid_to,
+ const std::string& type,
+ const std::string& condition,
+ const std::string& error_code,
+ const std::string& /* text */)
{
Stanza presence("presence");
presence["from"] = muc_name + "@" + this->served_hostname + "/" + nickname;
presence["to"] = jid_to;
+ presence["type"] = "error";
XmlNode x("x");
x["xmlns"] = MUC_NS;
x.close();
@@ -946,6 +930,8 @@ void XmppComponent::send_presence_error(const std::string& muc_name,
XmlNode error("error");
error["by"] = muc_name + "@" + this->served_hostname;
error["type"] = type;
+ if (!error_code.empty())
+ error["code"] = error_code;
XmlNode subnode(condition);
subnode["xmlns"] = STANZA_NS;
subnode.close();