Major changes to socket scheduling in EPoll.

This commit is contained in:
barant committed 2020-02-29 19:27:58 -08:00
1 parent 790906a6dc
commit a5a51f8aae
512 files changed
+22663 -2121

No files matched your search

+28 -9
View File
@@ -1,4 +1,5 @@
#include "CommandList.h"\
#include "CommandList.h"
#include "Log.h"
namespace core {
@@ -8,23 +9,41 @@ namespace core {
}
void CommandList::remove(Command &command) {
}
bool CommandList::processRequest(std::string request, TCPSession *session, std::stringstream &data) {
for(auto *command : commands) {
if(command->check(request)) {
command->processCommand(request, session, data);
return true;
}
}
return false;
std::stringstream input = std::stringstream(request);
while(!input.eof()) {
std::string requests;
std::getline(input, requests);
if(session->grab != NULL)
session->grab->processCommand(requests, session, data);
else {
int pos = requests.find(" ");
std::string function = pos == requests.npos ? requests: requests.substr(0, pos);
for(auto *command : commands)
if(command->check(function))
command->processCommand(requests, session, data);
}
}
return true;
}
bool CommandList::grabInput(TCPSession *session, Command &command) {
session->grab = &command;
}
void CommandList::clearGrab(TCPSession *session) {
session->grab = NULL;
}
int CommandList::processCommand(std::string request, TCPSession *session, std::stringstream &data) {
for(Command *command : commands)
data << command->getName() << std::endl;
}
}