Added: Handling requests to invite peers to lobby

This commit is contained in:
Konrad 2017-07-06 14:05:48 +02:00
parent 8e62a8b1b2
commit aca6233dbf
2 changed files with 21 additions and 0 deletions

View File

@ -169,6 +169,7 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
addResourceHandler("unsubscribe_lobby", this, &ChatHandler::handleUnsubscribeLobby);
addResourceHandler("autosubscribe_lobby", this, &ChatHandler::handleAutoSubsribeLobby);
addResourceHandler("clear_lobby", this, &ChatHandler::handleClearLobby);
addResourceHandler("invite_to_lobby", this, &ChatHandler::handleInviteToLobby);
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
addResourceHandler("messages", this, &ChatHandler::handleMessages);
addResourceHandler("send_message", this, &ChatHandler::handleSendMessage);
@ -936,6 +937,25 @@ void ChatHandler::handleClearLobby(Request &req, Response &resp)
resp.setOk();
}
void ChatHandler::handleInviteToLobby(Request& req, Response& resp)
{
std::string chat_id;
std::string pgp_id;
req.mStream << makeKeyValueReference("chat_id", chat_id);
req.mStream << makeKeyValueReference("pgp_id", pgp_id);
ChatId chatId(chat_id);
RsPgpId pgpId(pgp_id);
std::list<RsPeerId> peerIds;
mRsPeers->getAssociatedSSLIds(pgpId, peerIds);
for(std::list<RsPeerId>::iterator it = peerIds.begin(); it != peerIds.end(); it++)
mRsMsgs->invitePeerToLobby(chatId.toLobbyId(), (*it));
resp.setOk();
}
ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
{
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/

View File

@ -122,6 +122,7 @@ private:
void handleSubscribeLobby(Request& req, Response& resp);
void handleUnsubscribeLobby(Request& req, Response& resp);
void handleAutoSubsribeLobby(Request& req, Response& resp);
void handleInviteToLobby(Request& req, Response& resp);
void handleClearLobby(Request& req, Response& resp);
ResponseTask* handleLobbyParticipants(Request& req, Response& resp);
void handleMessages(Request& req, Response& resp);