<commit_before>#include "dsa_common.h"

#include "ws_client_connection.h"

#include <boost/asio/connect.hpp>

#include "module/logger.h"

namespace dsa {
WsClientConnection::WsClientConnection(LinkStrandRef &strand,
                                       const string_ &dsid_prefix,
                                       const string_ &host, uint16_t port)
    : WsConnection(*make_shared_<websocket_stream>(strand->get_io_service()),
                   strand, dsid_prefix),
      _hostname(host),
      _port(port) {}

void WsClientConnection::connect(size_t reconnect_interval) {
  // connect to server
  using tcp = boost::asio::ip::tcp;
  tcp::resolver resolver(_strand->get_io_service());
  // TODO: timeout
  LOG_INFO(_strand->logger(),
           LOG << "TCP client connecting to " << _hostname << ":" << _port);
  boost::asio::async_connect(
      _ws.next_layer(),
      resolver.resolve(tcp::resolver::query(_hostname, std::to_string(_port))),
      // capture shared_ptr to keep the instance
      // capture this to access protected member
      [ connection = share_this<WsConnection>(), this ](
          const boost::system::error_code &error,
          tcp::resolver::iterator) mutable {
        if (is_destroyed()) return;
        /* TODO
        if (error != boost::system::errc::success) {
          TcpConnection::destroy_in_strand(std::move(connection));
          // TODO: log or return the error?
          return;
        }
        */

        // websocket handshake
        _ws.async_handshake(_hostname, "/", [
          connection = share_this<WsConnection>(), this
        ](const boost::system::error_code &error) mutable {
          if (is_destroyed()) return;

          start_client_f0();

          WsConnection::start_read(std::move(connection));

        });

      });
  start_deadline_timer(reconnect_interval);
}

}  // namespace dsa
<commit_msg>disable websocket handshake portion until VS build issue is fixed<commit_after>#include "dsa_common.h"

#include "ws_client_connection.h"

#include <boost/asio/connect.hpp>

#include "module/logger.h"

namespace dsa {
WsClientConnection::WsClientConnection(LinkStrandRef &strand,
                                       const string_ &dsid_prefix,
                                       const string_ &host, uint16_t port)
    : WsConnection(*make_shared_<websocket_stream>(strand->get_io_service()),
                   strand, dsid_prefix),
      _hostname(host),
      _port(port) {}

void WsClientConnection::connect(size_t reconnect_interval) {
  // connect to server
  using tcp = boost::asio::ip::tcp;
  tcp::resolver resolver(_strand->get_io_service());
  // TODO: timeout
  LOG_INFO(_strand->logger(),
           LOG << "TCP client connecting to " << _hostname << ":" << _port);
  boost::asio::async_connect(
      _ws.next_layer(),
      resolver.resolve(tcp::resolver::query(_hostname, std::to_string(_port))),
      // capture shared_ptr to keep the instance
      // capture this to access protected member
      [ connection = share_this<WsConnection>(), this ](
          const boost::system::error_code &error,
          tcp::resolver::iterator) mutable {
        if (is_destroyed()) return;
        /* TODO
        if (error != boost::system::errc::success) {
          TcpConnection::destroy_in_strand(std::move(connection));
          // TODO: log or return the error?
          return;
        }
        */

#if 0
        // websocket handshake
        _ws.async_handshake(_hostname, "/", [
          connection = share_this<WsConnection>(), this
        ](const boost::system::error_code &error) mutable {
          if (is_destroyed()) return;

          start_client_f0();

          WsConnection::start_read(std::move(connection));

        });
#endif

      });
  start_deadline_timer(reconnect_interval);
}

}  // namespace dsa

{'fraction_non_alphanumeric': 0.1266614542611415, 'fraction_numerical': 0.0018243419338024498, 'mean_word_length': 2.672727272727273, 'pattern_counts': {'":': 2, '<': 27, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4615565', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1099, 'n_words': 218}