summaryrefslogtreecommitdiffstats
path: root/src/server/main.cpp
blob: 2d0fea8c6a1591a43dc76d2ed4d6a605faf5b3dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}