summaryrefslogtreecommitdiffstats
path: root/src/server/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/main.cpp')
-rw-r--r--src/server/main.cpp29
1 files changed, 29 insertions, 0 deletions
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 <stdio.h>
+
+#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