From ad0a2dc909fbb772d42ab6faf13bba74fbc2483d Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 2 Dec 2020 12:46:42 +0000 Subject: try to make the code is easier; start work with db --- src/server/main.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/server/main.cpp (limited to 'src/server/main.cpp') diff --git a/src/server/main.cpp b/src/server/main.cpp new file mode 100644 index 0000000..2d0fea8 --- /dev/null +++ b/src/server/main.cpp @@ -0,0 +1,29 @@ +#include + +#include "ChatServer.hpp" +#include "database.hpp" +#include "../config.hpp" + +int main(int argc, char *argv[]) +{ + /* Event-driven programming */ + /* + 1) selection event + 2) event handling + */ + DatabaseManager *db = DatabaseManager::Connect(DATABASE_HOST, DATABASE_USER, + DATABASE_PASSWD, DATABASE_DB, DATABASE_PORT); + if(!db) { + perror("database"); + return 1; + } + + EventSelector *selector = new EventSelector; + ChatServer *serv = ChatServer::Start(selector, db, SERVER_PORT); + if(!serv) { + perror("server"); + return 1; + } + selector->Run(); + return 0; +} \ No newline at end of file -- cgit v1.2.3-18-g5258