Samchon Framework for CPP  1.0.0
ChatRoom.hpp
1 #pragma once
2 #include <samchon/protocol/Entity.hpp>
3 #include <samchon/protocol/IProtocol.hpp>
4 
5 #include <string>
6 #include <samchon/library/CriticalSet.hpp>
7 
8 
9 namespace samchon
10 {
11  namespace example
12  {
13  namespace chat_service
14  {
15  class ChatUser;
16  class ChatService;
17 
18  class ChatRoomArray;
19 
33  class ChatRoom
34  : public protocol::Entity,
35  public protocol::IProtocol
36  {
37  protected:
38  typedef protocol::Entity super;
39 
40  virtual auto TAG() const -> std::string { return "room"; };
41 
42  private:
47 
52  std::string name;
53 
58 
62  library::CriticalSet<ChatService*> participants;
63 
64  public:
65  /* -----------------------------------------------------------
66  CONSTRUCTORS
67  ----------------------------------------------------------- */
75  ChatRoom(ChatRoomArray*, const std::string &, ChatUser*);
76  virtual ~ChatRoom() = default;
77 
83 
88  void eraseClient(ChatService*);
89 
90  /* -----------------------------------------------------------
91  CHAIN OF RESPONSIBILITY
92  ----------------------------------------------------------- */
93  virtual void replyData(std::shared_ptr<protocol::Invoke>) override;
94  virtual void sendData(std::shared_ptr<protocol::Invoke>) override;
95 
96  public:
97  /* -----------------------------------------------------------
98  GETTERS
99  ----------------------------------------------------------- */
100  virtual auto toXML() const -> std::shared_ptr<library::XML> override;
101  };
102  };
103  };
104 };
An entity, a standard data class.
Definition: Entity.hpp:115
ChatUser * host
A host, who established the room.
Definition: ChatRoom.hpp:57
library::CriticalSet< ChatService * > participants
Participants, ChatUser(s) in the room.
Definition: ChatRoom.hpp:62
ChatRoomArray * roomArray
All rooms that the room is belonged to.
Definition: ChatRoom.hpp:40
void registerClient(ChatService *)
Register a participant client.
void eraseClient(ChatService *)
Erase a participant client.
std::string name
Name of the room.
Definition: ChatRoom.hpp:52
ChatRoom(ChatRoomArray *, const std::string &, ChatUser *)
Construct from rooms, name and host.