libresapi: added chat/receive_status

usage:
$ curl http://<host:port>/localhost:8080/api/v2/chat/receive_status/<chat_id>
This commit is contained in:
electron128 2016-02-14 14:57:41 +01:00
parent fc5f8c3b8c
commit 2ab755bb5c
4 changed files with 121 additions and 99 deletions

View file

@ -26,6 +26,13 @@ public:
// note: this may get called from the own and from foreign threads
virtual void notifyChatMessage(const ChatMessage& msg);
// typing label for peer, broadcast and distant chat
virtual void notifyChatStatus (const ChatId& /* chat_id */, const std::string& /* status_string */);
//typing label for lobby chat, peer join and leave messages
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,
const RsGxsId& /* nickname */,const std::string& /* any string */);
// from tickable
virtual void tick();
@ -97,6 +104,15 @@ public:
std::string remote_author_name;
};
class TypingLabelInfo{
public:
time_t timestamp;
std::string status;
StateToken state_token;
// only for lobbies
RsGxsId author_id;
};
private:
void handleWildcard(Request& req, Response& resp);
void handleLobbies(Request& req, Response& resp);
@ -107,11 +123,13 @@ private:
void handleSendMessage(Request& req, Response& resp);
void handleMarkChatAsRead(Request& req, Response& resp);
void handleInfo(Request& req, Response& resp);
void handleTypingLabel(Request& req, Response& resp);
ResponseTask *handleReceiveStatus(Request& req, Response& resp);
void handleSendStatus(Request& req, Response& resp);
void handleUnreadMsgs(Request& req, Response& resp);
void getPlainText(const std::string& in, std::string &out, std::vector<Triple> &links);
// last parameter is only used for lobbies!
void locked_storeTypingInfo(const ChatId& chat_id, std::string status, RsGxsId lobby_gxs_id = RsGxsId());
StateTokenServer* mStateTokenServer;
RsNotify* mNotify;
@ -128,6 +146,8 @@ private:
std::map<ChatId, ChatInfo> mChatInfo;
std::map<ChatId, TypingLabelInfo> mTypingLabelInfo;
StateToken mLobbiesStateToken;
std::vector<Lobby> mLobbies;