Changeset - f592dc0ef3a6
[Not reviewed]
0 2 0
Jan Kaluza - 10 years ago 2015-12-28 09:17:41
jkaluza@redhat.com
Reconnect to Slack RTM when disconnected with an error
2 files changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
include/transport/WebSocketClient.h
Show inline comments
 
@@ -66,6 +66,7 @@ class WebSocketClient {
 
		void handleDNSResult(const std::vector<Swift::HostAddress>&, boost::optional<Swift::DomainNameResolveError>);
 
		void handleDataRead(boost::shared_ptr<Swift::SafeByteArray> data);
 
		void handleConnected(bool error);
 
		void handleDisconnected(const boost::optional<Swift::Connection::Error> &error);
 

	
 
		void connectServer();
 

	
libtransport/WebSocketClient.cpp
Show inline comments
 
@@ -208,10 +208,20 @@ void WebSocketClient::handleConnected(bool error) {
 
	m_conn->write(Swift::createSafeByteArray(req));
 
}
 

	
 
void WebSocketClient::handleDisconnected(const boost::optional<Swift::Connection::Error> &error) {
 
	if (!error) {
 
		return;
 
	}
 

	
 
	LOG4CXX_ERROR(logger, "Disconected from " << m_host << ". Will reconnect in 1 second.");
 
	m_reconnectTimer->start();
 
}
 

	
 
void WebSocketClient::handleDNSResult(const std::vector<Swift::HostAddress> &addrs, boost::optional<Swift::DomainNameResolveError>) {
 
	m_conn = m_tlsConnectionFactory->createConnection();
 
	m_conn->onDataRead.connect(boost::bind(&WebSocketClient::handleDataRead, this, _1));
 
	m_conn->onConnectFinished.connect(boost::bind(&WebSocketClient::handleConnected, this, _1));
 
	m_conn->onDisconnected.connect(boost::bind(&WebSocketClient::handleDisconnected, this, _1));
 
	m_conn->connect(Swift::HostAddressPort(addrs[0], 443));
 
}
 

	
0 comments (0 inline, 0 general)