mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-21 17:17:06 +02:00
Send list of active invites as part of room description
This commit is contained in:
parent
e12db20314
commit
a4ea74fbbc
@ -220,6 +220,15 @@ void GlobalLobbyClient::receiveActiveGameRooms(const JsonNode & json)
|
||||
account.displayName = jsonParticipant["displayName"].String();
|
||||
room.participants.push_back(account);
|
||||
}
|
||||
|
||||
for(const auto & jsonParticipant : jsonEntry["invited"].Vector())
|
||||
{
|
||||
GlobalLobbyAccount account;
|
||||
account.accountID = jsonParticipant["accountID"].String();
|
||||
account.displayName = jsonParticipant["displayName"].String();
|
||||
room.invited.push_back(account);
|
||||
}
|
||||
|
||||
room.playerLimit = jsonEntry["playerLimit"].Integer();
|
||||
|
||||
activeRooms.push_back(room);
|
||||
|
@ -29,6 +29,7 @@ struct GlobalLobbyRoom
|
||||
std::string startDateFormatted;
|
||||
ModCompatibilityInfo modList;
|
||||
std::vector<GlobalLobbyAccount> participants;
|
||||
std::vector<GlobalLobbyAccount> invited;
|
||||
int playerLimit;
|
||||
};
|
||||
|
||||
|
@ -65,6 +65,29 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"invited" :
|
||||
{
|
||||
"type" : "array",
|
||||
"description" : "List of accounts that were invited to this room",
|
||||
"items" :
|
||||
{
|
||||
"type" : "object",
|
||||
"additionalProperties" : false,
|
||||
"required" : [ "accountID", "displayName" ],
|
||||
"properties" : {
|
||||
"accountID" :
|
||||
{
|
||||
"type" : "string",
|
||||
"description" : "Unique ID of an account"
|
||||
},
|
||||
"displayName" :
|
||||
{
|
||||
"type" : "string",
|
||||
"description" : "Display name of an account"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mods" :
|
||||
{
|
||||
"type" : "array",
|
||||
|
@ -272,6 +272,13 @@ void LobbyDatabase::prepareStatements()
|
||||
ORDER BY secondsElapsed ASC
|
||||
)");
|
||||
|
||||
getGameRoomInvitesStatement = database->prepare(R"(
|
||||
SELECT a.accountID, a.displayName
|
||||
FROM gameRoomInvites gri
|
||||
LEFT JOIN accounts a ON a.accountID = gri.accountID
|
||||
WHERE roomID = ?
|
||||
)");
|
||||
|
||||
getGameRoomPlayersStatement = database->prepare(R"(
|
||||
SELECT a.accountID, a.displayName
|
||||
FROM gameRoomPlayers grp
|
||||
@ -581,6 +588,19 @@ std::vector<LobbyGameRoom> LobbyDatabase::getActiveGameRooms()
|
||||
}
|
||||
getGameRoomPlayersStatement->reset();
|
||||
}
|
||||
|
||||
for (auto & room : result)
|
||||
{
|
||||
getGameRoomInvitesStatement->setBinds(room.roomID);
|
||||
while(getGameRoomInvitesStatement->execute())
|
||||
{
|
||||
LobbyAccount account;
|
||||
getGameRoomInvitesStatement->getColumns(account.accountID, account.displayName);
|
||||
room.invited.push_back(account);
|
||||
}
|
||||
getGameRoomInvitesStatement->reset();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ class LobbyDatabase
|
||||
SQLiteStatementPtr getAccountGameRoomStatement;
|
||||
SQLiteStatementPtr getAccountDisplayNameStatement;
|
||||
SQLiteStatementPtr getGameRoomPlayersStatement;
|
||||
SQLiteStatementPtr getGameRoomInvitesStatement;
|
||||
SQLiteStatementPtr countRoomUsedSlotsStatement;
|
||||
SQLiteStatementPtr countRoomTotalSlotsStatement;
|
||||
|
||||
|
@ -47,6 +47,7 @@ struct LobbyGameRoom
|
||||
std::string version;
|
||||
std::string modsJson;
|
||||
std::vector<LobbyAccount> participants;
|
||||
std::vector<LobbyAccount> invited;
|
||||
LobbyRoomState roomState;
|
||||
uint32_t playerLimit;
|
||||
std::chrono::seconds age;
|
||||
|
@ -218,6 +218,9 @@ static JsonNode loadLobbyGameRoomToJson(const LobbyGameRoom & gameRoom)
|
||||
for(const auto & account : gameRoom.participants)
|
||||
jsonEntry["participants"].Vector().push_back(loadLobbyAccountToJson(account));
|
||||
|
||||
for(const auto & account : gameRoom.invited)
|
||||
jsonEntry["invited"].Vector().push_back(loadLobbyAccountToJson(account));
|
||||
|
||||
return jsonEntry;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user