Added: Handling requests to answer invitation to lobby

This commit is contained in:
Konrad 2017-07-06 14:08:50 +02:00
parent c9bfe4b526
commit 11d02f4612
2 changed files with 28 additions and 0 deletions

View File

@ -172,6 +172,7 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
addResourceHandler("clear_lobby", this, &ChatHandler::handleClearLobby);
addResourceHandler("invite_to_lobby", this, &ChatHandler::handleInviteToLobby);
addResourceHandler("get_invitations_to_lobby", this, &ChatHandler::handleGetInvitationsToLobby);
addResourceHandler("answer_to_invitation", this, &ChatHandler::handleAnswerToInvitation);
addResourceHandler("lobby_participants", this, &ChatHandler::handleLobbyParticipants);
addResourceHandler("messages", this, &ChatHandler::handleMessages);
addResourceHandler("send_message", this, &ChatHandler::handleSendMessage);
@ -986,6 +987,32 @@ void ChatHandler::handleGetInvitationsToLobby(Request& req, Response& resp)
resp.setOk();
}
void ChatHandler::handleAnswerToInvitation(Request& req, Response& resp)
{
ChatLobbyId lobbyId = 0;
req.mStream << makeKeyValueReference("lobby_id", lobbyId);
bool join;
req.mStream << makeKeyValueReference("join", join);
std::string gxs_id;
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
RsGxsId gxsId(gxs_id);
if(join)
{
if(rsMsgs->acceptLobbyInvite(lobbyId, gxsId))
resp.setOk();
else
resp.setFail();
}
else
{
rsMsgs->denyLobbyInvite(lobbyId);
resp.setOk();
}
}
ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
{
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/

View File

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