Added: Handling requests to create lobby

This commit is contained in:
Konrad 2017-04-14 17:44:17 +02:00
parent 93aeae0f59
commit fd33315146
2 changed files with 35 additions and 0 deletions

View File

@ -145,6 +145,7 @@ ChatHandler::ChatHandler(StateTokenServer *sts, RsNotify *notify, RsMsgs *msgs,
addResourceHandler("*", this, &ChatHandler::handleWildcard);
addResourceHandler("lobbies", this, &ChatHandler::handleLobbies);
addResourceHandler("create_lobby", this, &ChatHandler::handleCreateLobby);
addResourceHandler("subscribe_lobby", this, &ChatHandler::handleSubscribeLobby);
addResourceHandler("unsubscribe_lobby", this, &ChatHandler::handleUnsubscribeLobby);
addResourceHandler("autosubscribe_lobby", this, &ChatHandler::handleAutoSubsribeLobby);
@ -1210,4 +1211,37 @@ void ChatHandler::handleCloseDistantChatConnexion(Request& req, Response& resp)
else resp.setFail("Failed to close distant chat");
}
void ChatHandler::handleCreateLobby(Request& req, Response& resp)
{
std::set<RsPeerId> invited_identites;
std::string lobby_name;
std::string lobby_topic;
std::string gxs_id;
req.mStream << makeKeyValueReference("lobby_name", lobby_name);
req.mStream << makeKeyValueReference("lobby_topic", lobby_topic);
req.mStream << makeKeyValueReference("gxs_id", gxs_id);
RsGxsId gxsId(gxs_id);
bool lobby_public;
bool pgp_signed;
req.mStream << makeKeyValueReference("lobby_public", lobby_public);
req.mStream << makeKeyValueReference("pgp_signed", pgp_signed);
ChatLobbyFlags lobby_flags;
if(lobby_public)
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PUBLIC;
if(pgp_signed)
lobby_flags |= RS_CHAT_LOBBY_FLAGS_PGP_SIGNED;
mRsMsgs->createChatLobby(lobby_name, gxsId, lobby_topic, invited_identites, lobby_flags);
tick();
resp.setOk();
}
} // namespace resource_api

View File

@ -118,6 +118,7 @@ public:
private:
void handleWildcard(Request& req, Response& resp);
void handleLobbies(Request& req, Response& resp);
void handleCreateLobby(Request& req, Response& resp);
void handleSubscribeLobby(Request& req, Response& resp);
void handleUnsubscribeLobby(Request& req, Response& resp);
void handleAutoSubsribeLobby(Request& req, Response& resp);