You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

39 lines
1.0 KiB

#include "webserv.hpp"
Server::Server(JSONNode *server) {
JSONObject datas = server->obj();
if (datas["server_name"])
_name = datas["server_name"]->str();
if (datas["listens"]) {
JSONList listens = datas["listens"]->lst();
for (JSONList::iterator i = listens.begin(); i < listens.end(); i++) {
Socket *sock = new Socket((*i)->str());
if (sock->launch() == EXIT_SUCCESS)
_sockets.push_back(sock);
else
delete sock;
}
}
//_routes["default"] = new Route(datas["root"], datas["return"],
// datas["index"], datas["autoindex"]);
}
Server::~Server() {
cout << "Server destroyed!\n";
}
void Server::check() {
for (std::vector<Socket *>::iterator it = _sockets.begin();
it < _sockets.end(); it++) {
(*it)->check();
}
cout << "finished serv listen\n";
}
void Server::answer() {
for (std::vector<Socket *>::iterator it = _sockets.begin();
it < _sockets.end(); it++) {
(*it)->answer();
}
cout << "finished serv answer\n";
}