upd: writing cli

This commit is contained in:
2023-12-12 07:01:21 +00:00
parent 02767aae04
commit a7fcafca83
5 changed files with 64 additions and 16 deletions

View File

@ -1,13 +1,34 @@
#include "schedule.h"
#include "engine.h"
void BookStoreBackEndClass::Run()
{
#include <random>
#include <sstream>
#include "engine.h"
void BookStoreBackEndClass::Run() {
std::string request_data;
while(true)
{
const unsigned int RndSeed = std::random_device{}();
std::mt19937 rnd(RndSeed);
while (true) {
input_ptr->getline(request_data, '\n');
// std::string response_data = Engine::Process(request_data);
// output_ptr << response_data << '\n';
debugPrint("request_data=", request_data);
if (request_data[1] == 'O') // #OpenSession [TempChannelID]
{
std::stringstream ss;
ss << request_data;
ss >> request_data;
std::string TempChannelID;
ss >> TempChannelID;
SessionClass new_session;
std::string new_SessionToken;
std::string new_AuthenticationKey;
for (int i = 0; i < 16; i++) new_SessionToken.push_back(rnd() % 26 + 'A');
for (int i = 0; i < 16; i++)
new_AuthenticationKey.push_back(rnd() % 26 + 'A');
new_session.SessionToken = new_SessionToken;
new_session.OuthorizationKey = new_AuthenticationKey;
session_map[new_SessionToken] = new_session;
(*output_ptr) << TempChannelID << " IinitialOpt 1\n"
<< new_SessionToken << ' ' << new_AuthenticationKey << '\n';
}
}
}