Fixing command list delimiter depth.

This commit is contained in:
Brad Arant 2022-07-26 16:07:37 -07:00
parent 45aee7ab6f
commit 9af17daed6
5 changed files with 101 additions and 105 deletions

View File

@ -11,20 +11,20 @@ namespace core {
void CommandList::remove(Command &command) {} void CommandList::remove(Command &command) {}
bool CommandList::processRequest(coreutils::ZString &request, TCPSession &session) { int CommandList::processRequest(coreutils::ZString &request, TCPSession &session) {
if(session.grab != NULL) if(session.grab != NULL)
return session.grab->processCommand(request, session); return session.grab->processCommand(request, session);
else { else {
if(request.equals("")) if(request.equals(""))
return false; return 0;
request.split(delimiter, 10); request.split(delimiter, depth);
request.reset(); request.reset();
try { try {
auto command = commands.at(request[0].str()); auto command = commands.at(request[0].str());
return command->processCommand(request, session); return command->processCommand(request, session);
} }
catch(...) { catch(...) {
return false; return 0;
} }
} }
return true; return true;
@ -40,12 +40,9 @@ namespace core {
} }
int CommandList::processCommand(coreutils::ZString &request, TCPSession &session) { int CommandList::processCommand(coreutils::ZString &request, TCPSession &session) {
// for(Command *command : commands) // for(Command *command : commands)
// session.out << command->getName() << std::endl; // session.out << command->getName() << std::endl;
return true; return true;
} }
} }

View File

@ -40,7 +40,7 @@ namespace core {
/// then control is given to the process handler holding the grab on the input. /// then control is given to the process handler holding the grab on the input.
/// ///
bool processRequest(coreutils::ZString &request, TCPSession &session); int processRequest(coreutils::ZString &request, TCPSession &session);
/// ///
/// Use grabInput() within a Command object to force the requesting handler to receive /// Use grabInput() within a Command object to force the requesting handler to receive

View File

@ -1 +0,0 @@
0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos: 0.000000| pos:

View File

@ -18,7 +18,7 @@ namespace core {
void TCPSession::protocol(coreutils::ZString &data) { void TCPSession::protocol(coreutils::ZString &data) {
if(data.getLength() != 0) { if(data.getLength() != 0) {
if(!server.commands.processRequest(data, *this)) { if(server.commands.processRequest(data, *this) == 0) {
coreutils::Log(coreutils::LOG_DEBUG_1) << "Received data could not be parsed: " << data.str(); coreutils::Log(coreutils::LOG_DEBUG_1) << "Received data could not be parsed: " << data.str();
} }
} }