$treeview $search $mathjax $extrastylesheet
otsdaq_utilities
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 #ifndef _ots_ChatSupervisor_h 00002 #define _ots_ChatSupervisor_h 00003 00004 #include "otsdaq-core/CoreSupervisors/CoreSupervisorBase.h" 00005 00006 namespace ots 00007 { 00008 // ChatSupervisor 00009 // This class handles the otsdaq user chat functionality available in the web desktop 00010 // environment. 00011 class ChatSupervisor : public CoreSupervisorBase 00012 { 00013 public: 00014 XDAQ_INSTANTIATOR(); 00015 00016 ChatSupervisor(xdaq::ApplicationStub* s); 00017 virtual ~ChatSupervisor(void); 00018 00019 void destroy(void); 00020 00021 virtual void defaultPage(xgi::Input* in, xgi::Output* out) override; 00022 virtual void request(const std::string& requestType, 00023 cgicc::Cgicc& cgiIn, 00024 HttpXmlDocument& xmlOut, 00025 const WebUsers::RequestUserInfo& userInfo) override; 00026 00027 virtual void forceSupervisorPropertyValues(void) override; // override to force 00028 // supervisor property 00029 // values (and ignore user 00030 // settings) 00031 00032 private: 00033 //"Chat History" database associations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00034 // Maintain list of most recent chats and active display names 00035 // keep for set period (e.g. 10 sec) 00036 // each new chat is a string/displayName pair and is given a running index (0 is 00037 // skipped) 00038 std::vector<std::string> ChatHistoryEntry_, ChatHistoryAuthor_; 00039 std::vector<time_t> ChatHistoryTime_; 00040 std::vector<uint64_t> ChatHistoryIndex_; 00041 00042 uint64_t ChatLastUpdateIndex; 00043 00044 std::vector<std::string> ChatUsers_; 00045 std::vector<time_t> ChatUsersTime_; 00046 00047 enum 00048 { 00049 CHAT_HISTORY_EXPIRATION_TIME = 10, // 10 seconds 00050 CHAT_HISTORY_MAX_ENTRIES = 100, // 100 entries is vector max size 00051 }; 00052 00053 uint64_t incrementAndGetLastUpdate(); 00054 bool isLastUpdateIndexStale(uint64_t last); 00055 bool isChatOld(uint64_t chatIndex, uint64_t last); 00056 00057 void newUser(std::string user); 00058 void newChat(std::string chat, std::string user); 00059 void removeChatHistoryEntry(uint64_t i); 00060 void removeChatUserEntry(uint64_t i); 00061 void cleanupExpiredChats(); 00062 00063 void insertActiveUsers(HttpXmlDocument* xmldoc); 00064 void insertChatRefresh(HttpXmlDocument* xmldoc, 00065 uint64_t lastUpdateIndex, 00066 std::string user); 00067 00068 void escapeChat(std::string& chat); 00069 }; 00070 } 00071 00072 #endif