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 
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:48
ChatUser * host
A host, who established the room.
Definition: ChatRoom.hpp:57
Definition: RWMutex.hpp:4
void registerClient(ChatService *)
Register a participant client.
Definition: ChatRoom.cpp:30
library::CriticalSet< ChatService * > participants
Participants, ChatUser(s) in the room.
Definition: ChatRoom.hpp:62
ChatRoom(ChatRoomArray *, const std::string &, ChatUser *)
Construct from rooms, name and host.
Definition: ChatRoom.cpp:20
ChatRoomArray * roomArray
All rooms that the room is belonged to.
Definition: ChatRoom.hpp:40
An interface of Invoke message chain.
Definition: IProtocol.hpp:31
virtual auto toXML() const -> std::shared_ptr< library::XML > override
Get an XML object represents the Entity.
Definition: ChatRoom.cpp:85
virtual auto TAG() const -> std::string
A tag name when represented by XML.
Definition: ChatRoom.hpp:40
std::string name
Name of the room.
Definition: ChatRoom.hpp:52
std::set< T, _Pr, CriticalAllocator< T >> CriticalSet
A Set ensures concurrency.
Definition: CriticalSet.hpp:18
Top level namespace of products built from samchon.
Definition: ByteArray.hpp:7
void eraseClient(ChatService *)
Erase a participant client.
Definition: ChatRoom.cpp:37