Skip to content

Commit

Permalink
Add private game to API, hide sessionID for private (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotBlue-Dev authored Jan 28, 2024
1 parent 70a3f32 commit fe52f81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions EchoRelay.API/Controllers/Public/PublicSessionsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ public IActionResult Get()
foreach (var server in servers)
{
var gameServer = server.Value;
if(gameServer.SessionLobbyType != ERGameServerStartSession.LobbyType.Private)
var isPrivate = gameServer.SessionLobbyType == ERGameServerStartSession.LobbyType.Private;
if (gameServer.SessionStarted)
{
if (gameServer.SessionStarted)
{
publicSessions.Add(new PublicSessionInfo(gameServer));
}
publicSessions.Add(new PublicSessionInfo(gameServer, isPrivate));
}
}
Log.Debug("Returning {0} public sessions", publicSessions.Count());
Expand Down
4 changes: 2 additions & 2 deletions EchoRelay.API/Public/PublicSessionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class PublicSessionInfo
[JsonProperty("isPublic")]
public bool IsPublic { get; set; }

public PublicSessionInfo(RegisteredGameServer gameServer)
public PublicSessionInfo(RegisteredGameServer gameServer, bool isPrivate)
{
SessionId = gameServer.SessionId.ToString();
SessionId = isPrivate ? "" : gameServer.SessionId.ToString();
SessionIp = gameServer.ExternalAddress.ToString();
GameServerId = gameServer.ServerId;
ServerAddress = gameServer.Server.PublicIPAddress?.ToString() ?? "localhost";
Expand Down

0 comments on commit fe52f81

Please sign in to comment.