upd: ready to fix read in half way of write
This commit is contained in:
@ -35,9 +35,12 @@ class BlockingStringStream {
|
||||
BlockingStringStream &operator>>(T &val);
|
||||
BlockingStringStream &getline(std::string &str, char delim = '\n');
|
||||
std::stringstream internalStream;
|
||||
void lock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
std::mutex mutex;
|
||||
std::mutex custom_mutex;
|
||||
std::condition_variable condition;
|
||||
};
|
||||
// Implementation of operator<<
|
||||
@ -82,7 +85,7 @@ class ReadWriteLock {
|
||||
void endWrite();
|
||||
};
|
||||
class SessionClass {
|
||||
public:
|
||||
public:
|
||||
std::stack<int> login_stack;
|
||||
std::string SessionToken;
|
||||
std::string OuthorizationKey;
|
||||
|
@ -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(); }
|
@ -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';
|
||||
|
@ -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';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user