It works!!!
This commit is contained in:
1 parent
20d5c99517
commit
b7398afc05
16 files changed
+160
-197
No files matched your search
+31
-58
@@ -2,103 +2,76 @@
|
||||
#include "Log.h"
|
||||
|
||||
namespace core {
|
||||
|
||||
ConsoleSession::ConsoleSession(EPoll &ePoll, TCPServer &server) : TerminalSession(ePoll, server) {
|
||||
coreutils::Log(coreutils::LOG_DEBUG_2) << "Constructing ConsoleSession...";
|
||||
}
|
||||
|
||||
ConsoleSession::~ConsoleSession() {}
|
||||
|
||||
void ConsoleSession::protocol(coreutils::ZString data) {
|
||||
|
||||
coreutils::Log(coreutils::LOG_DEBUG_1) << "ConsoleSession protocol " << status;
|
||||
ConsoleSession::ConsoleSession(EPoll &ePoll, TCPServer &server) : TerminalSession(ePoll, server) {}
|
||||
|
||||
ConsoleSession::~ConsoleSession() {}
|
||||
|
||||
void ConsoleSession::protocol(coreutils::ZString &data) {
|
||||
|
||||
coreutils::ZString blank("");
|
||||
|
||||
switch (status) {
|
||||
|
||||
|
||||
case WELCOME:
|
||||
setBackColor(BG_BLACK);
|
||||
clear();
|
||||
setCursorLocation(1, 1);
|
||||
setBackColor(BG_BLUE);
|
||||
clearEOL();
|
||||
out << "ConsoleSession";
|
||||
setCursorLocation(2, 1);
|
||||
setBackColor(BG_BLACK);
|
||||
status = LOGIN;
|
||||
protocol((char*)"");
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
|
||||
case LOGIN:
|
||||
setCursorLocation(3, 3);
|
||||
out << "Enter User Profile: ";
|
||||
out << "User: ";
|
||||
status = WAIT_USER_PROFILE;
|
||||
break;
|
||||
|
||||
|
||||
case WAIT_USER_PROFILE:
|
||||
status = PASSWORD;
|
||||
protocol((char*)"");
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
|
||||
case PASSWORD:
|
||||
setCursorLocation(4, 7);
|
||||
out << "Enter Password: ";
|
||||
out << "Password: ";
|
||||
status = WAIT_PASSWORD;
|
||||
break;
|
||||
|
||||
case WAIT_PASSWORD:
|
||||
setBackColor(BG_BLACK);
|
||||
clear();
|
||||
setCursorLocation(1, 1);
|
||||
setBackColor(BG_BLUE);
|
||||
clearEOL();
|
||||
out << "ConsoleSession";
|
||||
setCursorLocation(2, 1);
|
||||
setBackColor(BG_BLACK);
|
||||
scrollArea(2, 16);
|
||||
status = PROMPT;
|
||||
protocol((char*)"");
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
|
||||
case PROMPT:
|
||||
setCursorLocation(17, 1);
|
||||
clearEOL();
|
||||
out << ("--> ");
|
||||
out << (": ");
|
||||
status = INPUT;
|
||||
break;
|
||||
|
||||
|
||||
case INPUT:
|
||||
command = data;
|
||||
status = PROCESS;
|
||||
protocol((char*)"");
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
|
||||
case PROCESS:
|
||||
doCommand(command);
|
||||
status = command.equals((char *)"exit") ? DONE: PROMPT;
|
||||
protocol((char*)"");
|
||||
break;
|
||||
|
||||
protocol(blank);
|
||||
break;
|
||||
|
||||
case DONE:
|
||||
out << "Done." << std::endl;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
out << "Unrecognized status code: ERROR.";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ConsoleSession::writeLog(std::string data) {
|
||||
saveCursor();
|
||||
setCursorLocation(16, 1);
|
||||
restoreCursor();
|
||||
}
|
||||
|
||||
void ConsoleSession::doCommand(coreutils::ZString request) {
|
||||
saveCursor();
|
||||
setCursorLocation(16, 1);
|
||||
out << "--> " << request << std::endl;
|
||||
|
||||
void ConsoleSession::doCommand(coreutils::ZString &request) {
|
||||
server.commands.processRequest(request, *this);
|
||||
restoreCursor();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user