Many changes
This commit is contained in:
1 parent
50bbfcc3c3
commit
46f98dff69
11 files changed
+110
-100
No files matched your search
+23
-23
@@ -2,43 +2,43 @@
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
|
||||
CommandList::CommandList(std::string delimiter) : delimiter(delimiter) {}
|
||||
|
||||
void CommandList::add(Command &command, std::string name) {
|
||||
command.setName(name);
|
||||
commands.push_back(&command);
|
||||
}
|
||||
|
||||
void CommandList::remove(Command &command) {
|
||||
|
||||
}
|
||||
|
||||
bool CommandList::processRequest(coreutils::ZString request, TCPSession *session, std::stringstream &data) {
|
||||
if(session->grab != NULL)
|
||||
return session->grab->processCommand(request, session, data);
|
||||
|
||||
void CommandList::remove(Command &command) {}
|
||||
|
||||
bool CommandList::processRequest(coreutils::ZString &request, TCPSession &session) {
|
||||
if(session.grab != NULL)
|
||||
return session.grab->processCommand(request, session);
|
||||
else {
|
||||
coreutils::ZString function = request.getTokenExclude((char *)" ");
|
||||
for(auto *command : commands)
|
||||
if(command->check(function))
|
||||
return command->processCommand(request, session, data);
|
||||
request.split(delimiter);
|
||||
for(auto *command : commands)
|
||||
if(command->check(request))
|
||||
return command->processCommand(request, session);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandList::grabInput(TCPSession *session, Command &command) {
|
||||
session->grab = &command;
|
||||
|
||||
bool CommandList::grabInput(TCPSession &session, Command &command) {
|
||||
session.grab = &command;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CommandList::clearGrab(TCPSession *session) {
|
||||
session->grab = NULL;
|
||||
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;
|
||||
|
||||
int CommandList::processCommand(coreutils::ZString &request, TCPSession &session) {
|
||||
for(Command *command : commands)
|
||||
session.out << command->getName() << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user