chatroom.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef __CHATROOM_H
  2. #define __CHATROOM_H
  3. #define MAX_USERS_IN_CHATROOM 50
  4. #include "datablock.h"
  5. #include "biglist.h"
  6. #include "message.h"
  7. #include <cstdint>
  8. class user; // Forward declaration https://stackoverflow.com/questions/8526819/c-header-files-including-each-other-mutually
  9. class chatclient;
  10. class chatroom
  11. {
  12. public:
  13. int64_t chatroomid;
  14. datablock *name;
  15. datablock *question;
  16. datablock *answer;
  17. datablock *answer_hashed;
  18. datablock *chatroomdata;
  19. bool everyone_can_join;
  20. bool delete_if_unused;
  21. biglist<chatclient *> clients;
  22. biglist<user *> allowed_users;
  23. // Methods:
  24. bool has_clients();
  25. int info(chatclient *client); // Some info describing this chatroom as a list of bitfields.
  26. int info(bool is_client_in_chatroom);
  27. void remove_client(chatclient *client);
  28. void add_client(chatclient *client);
  29. chatroom();
  30. ~chatroom();
  31. void clear();
  32. void initialize();
  33. static chatroom *find(biglist<chatroom *>*chatroom_list,int64_t chatroom_id);
  34. static chatroom *find(biglist<chatroom *>*chatroom_list,datastring chatroom_name);
  35. void send_message_to_clients(message *message);
  36. };
  37. #endif