void send_regular_msg(const FirstType& first_val, const RemArgTypes&... rem_args) { std::string orig_to_send, to_send; if (comm_type() == CommType::Discord) { orig_to_send += "``` "; } orig_to_send += sconcat(first_val, rem_args...); if (comm_type() == CommType::Discord) { orig_to_send += " ```"; } for (auto iter : orig_to_send) { //if ((comm_type() == CommType::Discord) // && ((iter == '\"') || (iter == '\\') // || (iter == '`'))) if ((comm_type() == CommType::Discord) && ((iter == '\"') || (iter == '\\'))) { to_send += '\\'; //if (iter == '`') //{ // to_send += '\\'; //} } to_send += iter; } //if (comm_type() == CommType::Discord) //{ // to_send += "\n\\`\\`\\`"; //} printout("Communicator::send_regular_msg(): ", to_send, "\n"); inner_send_regular_msg(std::move(to_send)); }
std::string const* MessageFactory::CreateInitMessage(std::string const& matchToken) const { Json::Value root; Json::FastWriter writer; Json::Value comm_type ("MatchConnect"); Json::Value match_token (matchToken); Json::Value team_name (USERNAME); Json::Value password (PASSWORD); root["comm_type"] = comm_type; root["match_token"] = match_token; root["team_name"] = team_name; root["password"] = password; std::string const* serialized = new std::string(writer.write(root)); return serialized; }
std::string const* MessageFactory::CreateMoveMessage(enum Tetromino::Move move, int pieceId) const { Json::Value root; Json::FastWriter writer; Json::Value comm_type ("GameMove"); Json::Value client_token (m_clientToken); root["comm_type"] = comm_type; root["client_token"] = client_token; if (move == Tetromino::left) { Json::Value moveV ("left"); root["move"] = moveV; } else if (move == Tetromino::right) { Json::Value moveV ("right"); root["move"] = moveV; } else if (move == Tetromino::down) { Json::Value moveV ("down"); root["move"] = moveV; } else if (move == Tetromino::lrotate) { Json::Value moveV ("lrotate"); root["move"] = moveV; } else if (move == Tetromino::rrotate) { Json::Value moveV ("rrotate"); root["move"] = moveV; } else if (move == Tetromino::drop) { Json::Value moveV ("drop"); root["move"] = moveV; } Json::Value number (pieceId); root["piece_number"] = number; std::string const* serialized = new std::string(writer.write(root)); return serialized; }