started documenting rsHistory.h to bring history to JSON api

This commit is contained in:
csoler 2021-07-03 00:31:09 +02:00
parent 9a6257e3c5
commit d6ccd75a7f

View File

@ -41,7 +41,7 @@ static const uint32_t RS_HISTORY_TYPE_PRIVATE = 1 ;
static const uint32_t RS_HISTORY_TYPE_LOBBY = 2 ; static const uint32_t RS_HISTORY_TYPE_LOBBY = 2 ;
static const uint32_t RS_HISTORY_TYPE_DISTANT = 3 ; static const uint32_t RS_HISTORY_TYPE_DISTANT = 3 ;
class HistoryMsg class HistoryMsg: RsSerializable
{ {
public: public:
HistoryMsg() HistoryMsg()
@ -52,7 +52,18 @@ public:
recvTime = 0; recvTime = 0;
} }
public: virtual void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext& ctx) override
{
RS_SERIAL_PROCESS(msgId);
RS_SERIAL_PROCESS(chatPeerId);
RS_SERIAL_PROCESS(incoming);
RS_SERIAL_PROCESS(peerId);
RS_SERIAL_PROCESS(peerName);
RS_SERIAL_PROCESS(sendTime);
RS_SERIAL_PROCESS(recvTime);
RS_SERIAL_PROCESS(message);
}
uint32_t msgId; uint32_t msgId;
RsPeerId chatPeerId; RsPeerId chatPeerId;
bool incoming; bool incoming;
@ -71,10 +82,34 @@ class RsHistory
{ {
public: public:
virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0; virtual bool chatIdToVirtualPeerId(const ChatId &chat_id, RsPeerId &peer_id) = 0;
virtual bool getMessages(const ChatId &chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
/*!
* @brief Retrieves the history of messages for a given chatId
* @jsonapi{development}
* @param[in] chatPeerId Chat Id for which the history needs to be retrieved
* @param[out] msgs retrieved messages
* @param[in] loadCount maximum number of messages to get
* @return true if messages can be retrieved, false otherwise.
*/
virtual bool getMessages(const ChatId& chatPeerId, std::list<HistoryMsg> &msgs, uint32_t loadCount) = 0;
/*!
* @brief Retrieves a specific message from the history
* @jsonapi{development}
* @param[in] msgId Id of the message to get
* @param[out] msg retrieved message
* @return true if message can be retrieved, false otherwise.
*/
virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0; virtual bool getMessage(uint32_t msgId, HistoryMsg &msg) = 0;
virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0; virtual void removeMessages(const std::list<uint32_t> &msgIds) = 0;
virtual void clear(const ChatId &chatPeerId) = 0;
/*!
* @brief clears the message history for a given chat peer
* @jsonapi{development}
* @param[in] chatPeerID Id of the chat/peer for which the history needs to be wiped
*/
virtual void clear(const ChatId &chatPeerId) = 0;
virtual bool getEnable(uint32_t chat_type) = 0; virtual bool getEnable(uint32_t chat_type) = 0;
virtual void setEnable(uint32_t chat_type, bool enable) = 0; virtual void setEnable(uint32_t chat_type, bool enable) = 0;