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 &operator>>(T &val);
|
||||||
BlockingStringStream &getline(std::string &str, char delim = '\n');
|
BlockingStringStream &getline(std::string &str, char delim = '\n');
|
||||||
std::stringstream internalStream;
|
std::stringstream internalStream;
|
||||||
|
void lock();
|
||||||
|
void unlock();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
|
std::mutex custom_mutex;
|
||||||
std::condition_variable condition;
|
std::condition_variable condition;
|
||||||
};
|
};
|
||||||
// Implementation of operator<<
|
// Implementation of operator<<
|
||||||
@ -82,7 +85,7 @@ class ReadWriteLock {
|
|||||||
void endWrite();
|
void endWrite();
|
||||||
};
|
};
|
||||||
class SessionClass {
|
class SessionClass {
|
||||||
public:
|
public:
|
||||||
std::stack<int> login_stack;
|
std::stack<int> login_stack;
|
||||||
std::string SessionToken;
|
std::string SessionToken;
|
||||||
std::string OuthorizationKey;
|
std::string OuthorizationKey;
|
||||||
|
@ -49,3 +49,6 @@ void debugPrint() {
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
BookStore_ZYM::debug_Print_Mutex.unlock();
|
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
|
input << "#Request " << SessionToken << " I-T-D " << AuthenticationKey
|
||||||
<< ' ' << cmd << '\n';
|
<< ' ' << cmd << '\n';
|
||||||
output.getline(tmp);
|
std::string SessionToken;
|
||||||
std::cout << tmp << std::endl;
|
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
|
input << "#CloseSession " << SessionToken << ' ' << AuthenticationKey
|
||||||
<< '\n';
|
<< '\n';
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "schedule.h"
|
#include "schedule.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@ -29,6 +30,29 @@ void BookStoreBackEndClass::Run() {
|
|||||||
session_map[new_SessionToken] = new_session;
|
session_map[new_SessionToken] = new_session;
|
||||||
(*output_ptr) << TempChannelID << " IinitialOpt 1\n"
|
(*output_ptr) << TempChannelID << " IinitialOpt 1\n"
|
||||||
<< new_SessionToken << ' ' << new_AuthenticationKey << '\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