push_Channel_class
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#ifndef CHANNEL_HPP
|
||||
# define CHANNEL_HPP
|
||||
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
||||
class Channel
|
||||
{
|
||||
private:
|
||||
std::string _name;
|
||||
std::string _topic;
|
||||
std::string _key;
|
||||
std::vector<int> _members;
|
||||
std::vector<int> _operators;
|
||||
std::vector<int> _invited;
|
||||
bool _inviteOnly;
|
||||
bool _topicRestricted;
|
||||
size_t _userLimit;
|
||||
|
||||
public:
|
||||
Channel(void);
|
||||
explicit Channel(const std::string &name);
|
||||
Channel(const Channel &other);
|
||||
Channel &operator=(const Channel &other);
|
||||
~Channel(void);
|
||||
|
||||
const std::string &getName(void) const;
|
||||
const std::string &getTopic(void) const;
|
||||
const std::string &getKey(void) const;
|
||||
size_t getUserLimit(void) const;
|
||||
bool isInviteOnly(void) const;
|
||||
bool isTopicRestricted(void) const;
|
||||
|
||||
void setTopic(const std::string &topic);
|
||||
void setKey(const std::string &key);
|
||||
void setUserLimit(size_t limit);
|
||||
void setInviteOnly(bool val);
|
||||
void setTopicRestricted(bool val);
|
||||
|
||||
bool hasMember(int fd) const;
|
||||
bool isOperator(int fd) const;
|
||||
bool isInvited(int fd) const;
|
||||
|
||||
void addMember(int fd);
|
||||
void removeMember(int fd);
|
||||
void addOperator(int fd);
|
||||
void removeOperator(int fd);
|
||||
void addInvited(int fd);
|
||||
void removeInvited(int fd);
|
||||
|
||||
const std::vector<int> &getMembers(void) const;
|
||||
size_t memberCount(void) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
+17
-6
@@ -15,6 +15,7 @@
|
||||
# include <cstring>
|
||||
# include <cerrno>
|
||||
# include "CommandValidator.hpp"
|
||||
# include "Channel.hpp"
|
||||
|
||||
struct ConnectedUser
|
||||
{
|
||||
@@ -39,18 +40,28 @@ class Server
|
||||
int _serverFd;
|
||||
int _port;
|
||||
std::string _password;
|
||||
std::vector<struct pollfd> _fds;
|
||||
std::vector<struct pollfd> _fds;
|
||||
std::map<int, ConnectedUser> _users;
|
||||
std::map<std::string, Channel> _channels;
|
||||
|
||||
void acceptNew(void);
|
||||
void handleRecv(int fd);
|
||||
void removeUser(int fd);
|
||||
void dispatch(int fd, const IrcMessage &msg);
|
||||
void handlePass(int fd, const IrcMessage &msg);
|
||||
void handleNick(int fd, const IrcMessage &msg);
|
||||
void handleUser(int fd, const IrcMessage &msg);
|
||||
void handlePing(int fd, const IrcMessage &msg);
|
||||
void handleQuit(int fd, const IrcMessage &msg);
|
||||
void broadcastToChannel(const std::string &chanName, const std::string &msg, int exceptFd);
|
||||
|
||||
void handlePass(int fd, const IrcMessage &msg);
|
||||
void handleNick(int fd, const IrcMessage &msg);
|
||||
void handleUser(int fd, const IrcMessage &msg);
|
||||
void handlePing(int fd, const IrcMessage &msg);
|
||||
void handleQuit(int fd, const IrcMessage &msg);
|
||||
void handleJoin(int fd, const IrcMessage &msg);
|
||||
void handlePart(int fd, const IrcMessage &msg);
|
||||
void handlePrivmsg(int fd, const IrcMessage &msg);
|
||||
void handleKick(int fd, const IrcMessage &msg);
|
||||
void handleInvite(int fd, const IrcMessage &msg);
|
||||
void handleTopic(int fd, const IrcMessage &msg);
|
||||
void handleMode(int fd, const IrcMessage &msg);
|
||||
|
||||
public:
|
||||
Server(int port, const std::string &password);
|
||||
|
||||
Reference in New Issue
Block a user