mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -05:00
Added: Handling requests to get lobbies invitations
This commit is contained in:
parent
aca6233dbf
commit
c9bfe4b526
@ -161,6 +161,7 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
|
|||||||
mMsgStateToken = mStateTokenServer->getNewToken();
|
mMsgStateToken = mStateTokenServer->getNewToken();
|
||||||
mLobbiesStateToken = mStateTokenServer->getNewToken();
|
mLobbiesStateToken = mStateTokenServer->getNewToken();
|
||||||
mUnreadMsgsStateToken = mStateTokenServer->getNewToken();
|
mUnreadMsgsStateToken = mStateTokenServer->getNewToken();
|
||||||
|
mInvitationsStateToken = mStateTokenServer->getNewToken();
|
||||||
|
|
||||||
addResourceHandler("*", this, &ChatHandler::handleWildcard);
|
addResourceHandler("*", this, &ChatHandler::handleWildcard);
|
||||||
addResourceHandler("lobbies", this, &ChatHandler::handleLobbies);
|
addResourceHandler("lobbies", this, &ChatHandler::handleLobbies);
|
||||||
@ -170,6 +171,7 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
|
|||||||
addResourceHandler("autosubscribe_lobby", this, &ChatHandler::handleAutoSubsribeLobby);
|
addResourceHandler("autosubscribe_lobby", this, &ChatHandler::handleAutoSubsribeLobby);
|
||||||
addResourceHandler("clear_lobby", this, &ChatHandler::handleClearLobby);
|
addResourceHandler("clear_lobby", this, &ChatHandler::handleClearLobby);
|
||||||
addResourceHandler("invite_to_lobby", this, &ChatHandler::handleInviteToLobby);
|
addResourceHandler("invite_to_lobby", this, &ChatHandler::handleInviteToLobby);
|
||||||
|
addResourceHandler("get_invitations_to_lobby", this, &ChatHandler::handleGetInvitationsToLobby);
|
||||||
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
|
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
|
||||||
addResourceHandler("messages", this, &ChatHandler::handleMessages);
|
addResourceHandler("messages", this, &ChatHandler::handleMessages);
|
||||||
addResourceHandler("send_message", this, &ChatHandler::handleSendMessage);
|
addResourceHandler("send_message", this, &ChatHandler::handleSendMessage);
|
||||||
@ -230,6 +232,15 @@ void ChatHandler::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatHandler::notifyListChange(int list, int type)
|
||||||
|
{
|
||||||
|
if(list == NOTIFY_LIST_CHAT_LOBBY_INVITATION)
|
||||||
|
{
|
||||||
|
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||||
|
mStateTokenServer->replaceToken(mInvitationsStateToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatHandler::tick()
|
void ChatHandler::tick()
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||||
@ -956,6 +967,25 @@ void ChatHandler::handleInviteToLobby(Request& req, Response& resp)
|
|||||||
resp.setOk();
|
resp.setOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatHandler::handleGetInvitationsToLobby(Request& req, Response& resp)
|
||||||
|
{
|
||||||
|
std::list<ChatLobbyInvite> invites;
|
||||||
|
mRsMsgs->getPendingChatLobbyInvites(invites);
|
||||||
|
|
||||||
|
resp.mDataStream.getStreamToMember();
|
||||||
|
for(std::list<ChatLobbyInvite>::const_iterator it = invites.begin(); it != invites.end(); ++it)
|
||||||
|
{
|
||||||
|
resp.mDataStream.getStreamToMember()
|
||||||
|
<< makeKeyValue("peer_id", (*it).peer_id.toStdString())
|
||||||
|
<< makeKeyValue("lobby_id", (*it).lobby_id)
|
||||||
|
<< makeKeyValue("lobby_name", (*it).lobby_name)
|
||||||
|
<< makeKeyValue("lobby_topic", (*it).lobby_topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
resp.mStateToken = mInvitationsStateToken;
|
||||||
|
resp.setOk();
|
||||||
|
}
|
||||||
|
|
||||||
ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
|
ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/
|
||||||
|
@ -35,6 +35,8 @@ public:
|
|||||||
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,
|
virtual void notifyChatLobbyEvent (uint64_t /* lobby id */, uint32_t /* event type */ ,
|
||||||
const RsGxsId& /* nickname */,const std::string& /* any string */);
|
const RsGxsId& /* nickname */,const std::string& /* any string */);
|
||||||
|
|
||||||
|
virtual void notifyListChange(int list, int type);
|
||||||
|
|
||||||
// from tickable
|
// from tickable
|
||||||
virtual void tick();
|
virtual void tick();
|
||||||
|
|
||||||
@ -123,6 +125,7 @@ private:
|
|||||||
void handleUnsubscribeLobby(Request& req, Response& resp);
|
void handleUnsubscribeLobby(Request& req, Response& resp);
|
||||||
void handleAutoSubsribeLobby(Request& req, Response& resp);
|
void handleAutoSubsribeLobby(Request& req, Response& resp);
|
||||||
void handleInviteToLobby(Request& req, Response& resp);
|
void handleInviteToLobby(Request& req, Response& resp);
|
||||||
|
void handleGetInvitationsToLobby(Request& req, Response& resp);
|
||||||
void handleClearLobby(Request& req, Response& resp);
|
void handleClearLobby(Request& req, Response& resp);
|
||||||
ResponseTask* handleLobbyParticipants(Request& req, Response& resp);
|
ResponseTask* handleLobbyParticipants(Request& req, Response& resp);
|
||||||
void handleMessages(Request& req, Response& resp);
|
void handleMessages(Request& req, Response& resp);
|
||||||
@ -163,6 +166,7 @@ private:
|
|||||||
std::map<ChatLobbyId, LobbyParticipantsInfo> mLobbyParticipantsInfos;
|
std::map<ChatLobbyId, LobbyParticipantsInfo> mLobbyParticipantsInfos;
|
||||||
|
|
||||||
StateToken mUnreadMsgsStateToken;
|
StateToken mUnreadMsgsStateToken;
|
||||||
|
StateToken mInvitationsStateToken;
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace resource_api
|
} // namespace resource_api
|
||||||
|
Loading…
x
Reference in New Issue
Block a user