Connection to servers does not block the process anymore
This commit is contained in:
@@ -50,9 +50,9 @@ XmppComponent::~XmppComponent()
|
||||
{
|
||||
}
|
||||
|
||||
bool XmppComponent::start()
|
||||
void XmppComponent::start()
|
||||
{
|
||||
return this->connect("127.0.0.1", "5347").first;
|
||||
this->connect("127.0.0.1", "5347");
|
||||
}
|
||||
|
||||
bool XmppComponent::is_document_open() const
|
||||
@@ -67,6 +67,11 @@ void XmppComponent::send_stanza(const Stanza& stanza)
|
||||
this->send_data(std::move(str));
|
||||
}
|
||||
|
||||
void XmppComponent::on_connection_failed(const std::string& reason)
|
||||
{
|
||||
log_error("Failed to connect to the XMPP server: " << reason);
|
||||
}
|
||||
|
||||
void XmppComponent::on_connected()
|
||||
{
|
||||
log_info("connected to XMPP server");
|
||||
@@ -103,7 +108,7 @@ void XmppComponent::clean()
|
||||
while (it != this->bridges.end())
|
||||
{
|
||||
it->second->clean();
|
||||
if (it->second->connected_clients() == 0)
|
||||
if (it->second->active_clients() == 0)
|
||||
it = this->bridges.erase(it);
|
||||
else
|
||||
++it;
|
||||
|
||||
@@ -20,6 +20,7 @@ class XmppComponent: public SocketHandler
|
||||
public:
|
||||
explicit XmppComponent(const std::string& hostname, const std::string& secret);
|
||||
~XmppComponent();
|
||||
void on_connection_failed(const std::string& reason) override final;
|
||||
void on_connected() override final;
|
||||
void on_connection_close() override final;
|
||||
void parse_in_buffer() override final;
|
||||
@@ -38,9 +39,8 @@ public:
|
||||
void clean();
|
||||
/**
|
||||
* Connect to the XMPP server.
|
||||
* Returns false if we failed to connect
|
||||
*/
|
||||
bool start();
|
||||
void start();
|
||||
/**
|
||||
* Serialize the stanza and add it to the out_buf to be sent to the
|
||||
* server.
|
||||
|
||||
Reference in New Issue
Block a user