Last active
August 10, 2018 19:53
-
-
Save sangfansh/d1728c9fb3567734b1afd2d4a65ef457 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Client::startConnection() { | |
Log("Start connecting..."); | |
boost::system::error_code ec; | |
boost::asio::connect(socket_.lowest_layer(), this->endpoint_iterator, ec); | |
handle_connect(ec); | |
} | |
void Client::handle_connect(const boost::system::error_code &error) { | |
if (!error) { | |
Log("Connection established"); | |
boost::system::error_code ec; | |
socket_.handshake(boost::asio::ssl::stream_base::client, ec); | |
handle_handshake(ec); | |
} else { | |
Log("Connect failed: %s", error.message(), log::error); | |
} | |
} | |
void Client::handle_handshake(const boost::system::error_code& error) { | |
if (!error) { | |
Log("Handshake successful"); | |
auto ret = this->callback_handler("", -1); | |
send(ret); | |
} else { | |
Log("Handshake failed: %s", error.message(), log::error); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment