Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreidheim <eidheim@gmail.com>2017-07-18 14:32:15 +0300
committereidheim <eidheim@gmail.com>2017-07-18 20:00:40 +0300
commit8adec12931d42715beeb50f61a0c7d3692862e85 (patch)
treef8daab51406deabe022b0c39defaea2552d0bb97 /client_wss.hpp
parentce7f6246b8617b8d79b4efaa1d86b74e82dd1b65 (diff)
Moved send/send_close from Server/Client to Connection::send/send_close. Also, path now split into path and query_string, and some additional cleanup.
Diffstat (limited to 'client_wss.hpp')
-rw-r--r--client_wss.hpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/client_wss.hpp b/client_wss.hpp
index b318d4b..a00ffef 100644
--- a/client_wss.hpp
+++ b/client_wss.hpp
@@ -43,13 +43,14 @@ namespace SimpleWeb {
void connect() {
asio::ip::tcp::resolver::query query(host, std::to_string(port));
-
- resolver->async_resolve(query, [this](const error_code &ec, asio::ip::tcp::resolver::iterator it) {
+ auto resolver = std::make_shared<asio::ip::tcp::resolver>(*io_service);
+ resolver->async_resolve(query, [this, resolver](const error_code &ec, asio::ip::tcp::resolver::iterator it) {
if(!ec) {
- auto connection = std::shared_ptr<Connection>(new Connection(*io_service, context));
- current_connection = connection;
+ std::unique_lock<std::mutex> lock(connection_mutex);
+ auto connection = this->connection = std::shared_ptr<Connection>(new Connection(*io_service, context));
+ lock.unlock();
- asio::async_connect(connection->socket->lowest_layer(), it, [this, connection](const error_code &ec, asio::ip::tcp::resolver::iterator /*it*/) {
+ asio::async_connect(connection->socket->lowest_layer(), it, [this, connection, resolver](const error_code &ec, asio::ip::tcp::resolver::iterator /*it*/) {
if(!ec) {
asio::ip::tcp::no_delay option(true);
connection->socket->lowest_layer().set_option(option);