summaryrefslogtreecommitdiff
path: root/src/xmpp/xmpp_component.cpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-21 21:04:41 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-01-04 01:59:14 +0100
commit3afb63a650b8b925ce1ba722dd42b7418f623713 (patch)
tree594cdfdd2a0abf302229ec000c2177ec001bfeaf /src/xmpp/xmpp_component.cpp
parentdf59a09163bd988ad4da533c4f39de057a3701ba (diff)
downloadbiboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.gz
biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.bz2
biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.tar.xz
biboumi-3afb63a650b8b925ce1ba722dd42b7418f623713.zip
Shutdown cleanly on SIGINT
Diffstat (limited to 'src/xmpp/xmpp_component.cpp')
-rw-r--r--src/xmpp/xmpp_component.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 433f87a..dc77934 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -24,7 +24,8 @@
XmppComponent::XmppComponent(const std::string& hostname, const std::string& secret):
served_hostname(hostname),
secret(secret),
- authenticated(false)
+ authenticated(false),
+ doc_open(false)
{
this->parser.add_stream_open_callback(std::bind(&XmppComponent::on_remote_stream_open, this,
std::placeholders::_1));
@@ -51,6 +52,11 @@ bool XmppComponent::start()
return this->connect("127.0.0.1", "5347");
}
+bool XmppComponent::is_document_open() const
+{
+ return this->doc_open;
+}
+
void XmppComponent::send_stanza(const Stanza& stanza)
{
std::string str = stanza.to_string();
@@ -66,6 +72,7 @@ void XmppComponent::on_connected()
node["xmlns:stream"] = STREAM_NS;
node["to"] = this->served_hostname;
this->send_stanza(node);
+ this->doc_open = true;
}
void XmppComponent::on_connection_close()
@@ -79,6 +86,14 @@ void XmppComponent::parse_in_buffer()
this->in_buf.clear();
}
+void XmppComponent::shutdown()
+{
+ for (auto it = this->bridges.begin(); it != this->bridges.end(); ++it)
+ {
+ it->second->shutdown();
+ }
+}
+
void XmppComponent::on_remote_stream_open(const XmlNode& node)
{
log_debug("XMPP DOCUMENT OPEN: " << node.to_string());
@@ -145,6 +160,7 @@ void XmppComponent::close_document()
{
log_debug("XMPP SENDING: </stream:stream>");
this->send_data("</stream:stream>");
+ this->doc_open = false;
}
void XmppComponent::handle_handshake(const Stanza& stanza)