upd: ready to fix read in half way of write

This commit is contained in:
2023-12-12 07:29:45 +00:00
parent a7fcafca83
commit ffb1a5f788
4 changed files with 41 additions and 4 deletions

View File

@ -48,4 +48,7 @@ void debugPrint() {
BookStore_ZYM::debug_Print_Mutex.lock();
std::cerr << std::endl;
BookStore_ZYM::debug_Print_Mutex.unlock();
}
}
void BlockingStringStream::lock() { custom_mutex.lock(); }
void BlockingStringStream::unlock() { custom_mutex.unlock(); }

View File

@ -28,8 +28,15 @@ void BookStoreMain(bool is_server, std::string config_dir) {
}
input << "#Request " << SessionToken << " I-T-D " << AuthenticationKey
<< ' ' << cmd << '\n';
output.getline(tmp);
std::cout << tmp << std::endl;
std::string SessionToken;
std::string OperationToken;
int LineCounter;
continue;
output >> SessionToken >> OperationToken >> LineCounter;
for (int i = 0; i < LineCounter; i++) {
output.getline(tmp);
std::cout << tmp << std::endl;
}
}
input << "#CloseSession " << SessionToken << ' ' << AuthenticationKey
<< '\n';

View File

@ -1,5 +1,6 @@
#include "schedule.h"
#include <iostream>
#include <random>
#include <sstream>
@ -29,6 +30,29 @@ void BookStoreBackEndClass::Run() {
session_map[new_SessionToken] = new_session;
(*output_ptr) << TempChannelID << " IinitialOpt 1\n"
<< new_SessionToken << ' ' << new_AuthenticationKey << '\n';
} else if (request_data[1] == 'C') {
;
} else if (request_data[1] == '_') {
;
} else if (request_data[1] == 'S') {
;
} else if (request_data[1] == 'R') {
std::stringstream ss(request_data);
std::string SessionToken;
std::string OperationToken;
std::string OuthenticationKey;
std::string cmd;
ss >> cmd >> SessionToken >> OperationToken >> OuthenticationKey;
ss.get();
std::getline(ss, cmd);
debugPrint("SessionToken=", SessionToken,
" OperationToken=", OperationToken,
" OuthenticationKey=", OuthenticationKey, " cmd=", cmd);
// (*output_ptr) << SessionToken << ' ' << OperationToken << " 0\n";
(*output_ptr) << SessionToken << ' ' << OperationToken
<< " 1\nECHO: " << cmd << '\n';
// std::cerr << "[]" << SessionToken << ' ' << OperationToken
// << " 1\nECHO: " << cmd << '\n';
}
}
}