4 #include <unordered_map> 8 #include "server/storage/database.h" 9 #include "server/log/logger.h" 28 Channel(identifier_t room, database_ptr db) : channel_id(room)
31 BOOST_LOG_TRIVIAL(info) <<
"Failed to load history. Database pointer is nullptr.";
33 history_room = db->get_history(channel_id);
34 BOOST_LOG_TRIVIAL(info) <<
"Create channel_id=" << channel_id;
43 virtual void join(subscriber_ptr subscriber)
override;
50 virtual void leave(subscriber_ptr subscriber)
override;
56 virtual void notification(text_response_ptr response)
override;
64 virtual identifier_t
get_room_id()
const override {
return channel_id; }
67 for(
auto it:subscribers) {
72 std::mutex mutex_subs;
73 std::unordered_map<identifier_t, subscriber_ptr> subscribers;
76 const identifier_t channel_id;
78 std::deque<text_response_ptr> history_room;
81 using channel_ptr = std::shared_ptr<Channel>;
Channel(identifier_t room, database_ptr db)
Construct a new Channel.
Definition: channel.h:28
virtual void notification(text_response_ptr response) override
Notify all channel subscribers about new message.
Definition: channel.cpp:30
Channel class.
Definition: channel.h:18
virtual void leave(subscriber_ptr subscriber) override
Leave a user from channel.
Definition: channel.cpp:18
virtual identifier_t get_room_id() const override
Get the room id object.
Definition: channel.h:64
virtual void join(subscriber_ptr subscriber) override
Join a user to channel.
Definition: channel.cpp:4
Room interface.
Definition: iroom.h:14