merge branch samy

This commit is contained in:
Samy Ben Tayeb 2025-05-20 17:15:30 +02:00
commit 15cceeecd2
7 changed files with 337 additions and 226 deletions

View file

@ -0,0 +1,22 @@
#pragma once
#include <map>
#include <vector>
#include <string>
class PollManager {
public:
PollManager();
~PollManager();
void addClient(int fd);
void removeClient(int fd);
void updateServer(int fd);
void pollLoop(int server_fd);
private:
std::vector<struct pollfd> _fds;
std::map<int, std::string> _buffers;
};

View file

@ -1,32 +1,36 @@
/******************************************************************************/
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* server.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
/* By: sben-tay <sben-tay@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/13 11:06:56 by rparodi #+# #+# */
/* Updated: 2025/05/19 20:12:46 by omoudni ### ########.fr */
/* Updated: 2025/05/20 17:11:56 by sben-tay ### ########.fr */
/* */
/******************************************************************************/
/* ************************************************************************** */
#pragma once
#include "core.hpp"
#include <string>
#include "PollManager.hpp"
class Server {
private:
unsigned short int _port;
std::string _password;
int server_fd;
PollManager _pollManager;
public:
Server();
Server(int port, const std::string &password);
~Server();
void showInfo() const;
unsigned short int getPort() const;
void setServerFd(int fd);
void start();
public:
Server();
Server(int port, const std::string &password);
~Server();
unsigned short int getPort() const;
void showInfo() const;
void setServerFd(int fd);
void start();
private:
unsigned short int _port;
int _serverFd;
std::string _password;
PollManager _poll;
};