<commit_before># // sets delimiter, until which the serial is going to read in order to retrieve messages
#include "client.hpp"

const char Client::delimiter{'~'}; // sets delimiter, until which the serial is going to read in order to retrieve messages

Client::Client(std::string userName, int baud) : // constructor
  serial("/dev/ttyACM0", baud),   // initializes serial-port
  userName(userName)      // sets client's userName
{
  // std::cout << "finished constructing client '" << userName << std::endl;
}

void Client::setUsername(std::string name) {  // sets client's userName
  sendExpression("server", "CHANGENAME "+name+" "+userName);
  userName = name;
}

// retrieves the servers on the network by making a ping request and retrieving the server response
std::string Client::getServers() {
  std::string servers;
  // std::cout << "Attempting to get servers" << std::endl;
  // std::cout << "Sending Ping" << std::endl;
  for (int i{0}; i < 3; ++i) {
    sendExpression("server","PING");
    serial.readUntil(delimiter);
  }

  sendExpression("server","PING");
  Envelope pong(retrieveEnvelope());
  // std::cout << "received server pong envelope '" << pong.toString() << "'" << std::endl;
  servers += pong.getServer()+"\n";


    // std::cout << "returning server set" << std::endl;
  return servers;
}

// connects to the server by sending an expressing and changes the serverName associated with the client
void Client::connectServer(std::string server) {
    // std::cout << "Sending a request to '" << server << "' for connection" << std::endl;
  sendExpression("server","CONNECT "+userName);
  serverName = server;
}

void Client::disconnectServer() {
  sendExpression("server", "DISCONNECT "+serverName);
  serverName = "";
}

// std::set<std::string> Client::getChannels() {
//   std::cout << "Attempting to get channel listing" << std::endl;
//   std::cout << "Sending a server request for getchannels" << std::endl;
//   sendServerRequest("GETCHANNELS");
//   std::cout << "server request for channel listing sent" << std::endl;

//   std::set<std::string> channels;
//   std::cout << "getting channel listing response..." << std::endl;
//   std::string response(retrieveResponse());
//   std::cout << "received channel listing response '" << response << "'" << std::endl;

//   std::cout << "splitting channel listing by spaces" << std::endl;<commit_msg>fixed disconnect syntax<commit_after># // sets delimiter, until which the serial is going to read in order to retrieve messages
#include "client.hpp"

const char Client::delimiter{'~'}; // sets delimiter, until which the serial is going to read in order to retrieve messages

Client::Client(std::string userName, int baud) : // constructor
  serial("/dev/ttyACM0", baud),   // initializes serial-port
  userName(userName)      // sets client's userName
{
  // std::cout << "finished constructing client '" << userName << std::endl;
}

void Client::setUsername(std::string name) {  // sets client's userName
  sendExpression("server", "CHANGENAME "+name+" "+userName);
  userName = name;
}

// retrieves the servers on the network by making a ping request and retrieving the server response
std::string Client::getServers() {
  std::string servers;
  // std::cout << "Attempting to get servers" << std::endl;
  // std::cout << "Sending Ping" << std::endl;
  for (int i{0}; i < 3; ++i) {
    sendExpression("server","PING");
    serial.readUntil(delimiter);
  }

  sendExpression("server","PING");
  Envelope pong(retrieveEnvelope());
  // std::cout << "received server pong envelope '" << pong.toString() << "'" << std::endl;
  servers += pong.getServer()+"\n";


    // std::cout << "returning server set" << std::endl;
  return servers;
}

// connects to the server by sending an expressing and changes the serverName associated with the client
void Client::connectServer(std::string server) {
    // std::cout << "Sending a request to '" << server << "' for connection" << std::endl;
  sendExpression("server","CONNECT "+userName);
  serverName = server;
}

void Client::disconnectServer() {
  sendExpression("server", "DISCONNECT "+serverName+" "+userName);
  serverName = "";
}

// std::set<std::string> Client::getChannels() {
//   std::cout << "Attempting to get channel listing" << std::endl;
//   std::cout << "Sending a server request for getchannels" << std::endl;
//   sendServerRequest("GETCHANNELS");
//   std::cout << "server request for channel listing sent" << std::endl;

//   std::set<std::string> channels;
//   std::cout << "getting channel listing response..." << std::endl;
//   std::string response(retrieveResponse());
//   std::cout << "received channel listing response '" << response << "'" << std::endl;

//   std::cout << "splitting channel listing by spaces" << std::endl;
{'fraction_non_alphanumeric': 0.16942062330056473, 'fraction_numerical': 0.0012549675800041832, 'mean_word_length': 4.360986547085202, 'pattern_counts': {'":': 0, '<': 133, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4958196', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1381, 'n_words': 426}