Chat.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #pragma once
  2. #include "ChatCommandExecutor.h"
  3. #include "ChatMessage.h"
  4. #include "ChatObserver.h"
  5. class Chat : public virtual Framework::ReferenceCounter
  6. {
  7. public:
  8. static const Framework::Text CHANNEL_INFO;
  9. static const Framework::Text CHANNEL_WARNING;
  10. static const Framework::Text CHANNEL_ERROR;
  11. private:
  12. ChatCommandExecutor* commandExecutor;
  13. Framework::RCArray<ChatMessage> history;
  14. Framework::RCArray<ChatObserver> observer;
  15. Framework::Critical cs;
  16. void addMessage(ChatMessage* message);
  17. public:
  18. Chat();
  19. ~Chat();
  20. void addObserver(int entityId);
  21. void removeObserver(int entityId);
  22. void chatApi(Framework::StreamReader* zRequest,
  23. Entity* zSource,
  24. NetworkMessage* zResponse);
  25. void broadcastMessage(Framework::Text message, Framework::Text channel);
  26. void sendMessageTo(
  27. Framework::Text message, Entity* zTarget, Framework::Text channel);
  28. void save();
  29. ChatCommandExecutor* zCommandExecutor() const;
  30. static Framework::Text getPlayerChannelName(Framework::Text playerName);
  31. };