Bläddra i källkod

Send list of active invites as part of room description

Ivan Savenko 1 år sedan
förälder
incheckning
a4ea74fbbc

+ 9 - 0
client/globalLobby/GlobalLobbyClient.cpp

@@ -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);

+ 1 - 0
client/globalLobby/GlobalLobbyDefines.h

@@ -29,6 +29,7 @@ struct GlobalLobbyRoom
 	std::string startDateFormatted;
 	ModCompatibilityInfo modList;
 	std::vector<GlobalLobbyAccount> participants;
+	std::vector<GlobalLobbyAccount> invited;
 	int playerLimit;
 };
 

+ 23 - 0
config/schemas/lobbyProtocol/activeGameRooms.json

@@ -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",

+ 20 - 0
lobby/LobbyDatabase.cpp

@@ -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;
 }
 

+ 1 - 0
lobby/LobbyDatabase.h

@@ -48,6 +48,7 @@ class LobbyDatabase
 	SQLiteStatementPtr getAccountGameRoomStatement;
 	SQLiteStatementPtr getAccountDisplayNameStatement;
 	SQLiteStatementPtr getGameRoomPlayersStatement;
+	SQLiteStatementPtr getGameRoomInvitesStatement;
 	SQLiteStatementPtr countRoomUsedSlotsStatement;
 	SQLiteStatementPtr countRoomTotalSlotsStatement;
 

+ 1 - 0
lobby/LobbyDefines.h

@@ -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;

+ 3 - 0
lobby/LobbyServer.cpp

@@ -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;
 }