ServerCore/testing/main.cpp
2025-01-28 16:26:40 -08:00

39 lines
1.0 KiB
C++

#include "EPoll.h"
#include "ConsoleServer.h"
#include "Exception.h"
#include "File.h"
#include "Log.h"
#include "IPAddress.h"
#include <iostream>
int main(int argc, char **argv) {
try {
coreutils::Log(new coreutils::File("/tmp/console.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
coreutils::Log(coreutils::LOG_INFO) << "Console Server starting. Build " << __DATE__ << " " << __TIME__;
std::string ipAddress = "0.0.0.0";
core::EPoll ePoll;
core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027));
console.commands.add(ePoll, "threads");
console.commands.add(console, "consoles");
console.commands.add(console.commands, "help");
ePoll.start(2, 1000);
while(true)
sleep(300);
ePoll.stop();
}
catch(coreutils::Exception exception) {
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
}
}