Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tpill90 committed Oct 11, 2024
1 parent 7cf7190 commit ab7870e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion LancachePrefill.Common
11 changes: 9 additions & 2 deletions SteamPrefill/Handlers/Steam/Steam3Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public Steam3Session(IAnsiConsole ansiConsole)

_steamClient = new SteamClient(SteamConfiguration.Create(e => e.WithCellID(CellId)
// TODO remove this line when this PR is merged and deployed https://github.com/SteamRE/SteamKit/pull/1420
//TODO seems to no longer work
.WithProtocolTypes(ProtocolTypes.WebSocket)
.WithConnectionTimeout(TimeSpan.FromSeconds(10))));

Expand Down Expand Up @@ -99,6 +100,12 @@ public Steam3Session(IAnsiConsole ansiConsole)

_userAccountStore = UserAccountStore.LoadFromFile();
LicenseManager = new LicenseManager(SteamAppsApi);

// Setting up optional SteamKit2 debug output. Not enabled by default because it writes out way too much output that isn't useful outside of debugging.
if (AppConfig.DebugLogs)
{
DebugLog.AddListener(new SteamKitDebugListener(_ansiConsole));
}
}

public async Task LoginToSteamAsync()
Expand Down Expand Up @@ -133,7 +140,7 @@ await _ansiConsole.StatusSpinner().StartAsync("Connecting to Steam...", async ct
}
}

_ansiConsole.LogMarkupVerbose($"Connected to CM {LightYellow(_steamClient.CurrentEndPoint)}");
_ansiConsole.LogMarkupVerbose($"Connected to CM {Cyan(_steamClient.CurrentEndPoint)}");
}

private async Task GetAccessTokenAsync()
Expand Down Expand Up @@ -226,7 +233,7 @@ private SteamUser.LoggedOnCallback AttemptSteamLogin()
_loggedOnCallbackResult = null;

_logonDetails.AccessToken = _userAccountStore.AccessToken;
_steamUser.LogOn(_logonDetails);
_steamClient.GetHandler<SteamUser>().LogOn(_logonDetails);

// Busy waiting for the callback to complete, then we can return the callback value synchronously
while (_loggedOnCallbackResult == null)
Expand Down
11 changes: 10 additions & 1 deletion SteamPrefill/Handlers/Steam/SteamKitDebugListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ public sealed class SteamKitDebugListener : IDebugListener

public SteamKitDebugListener(IAnsiConsole ansiConsole)
{
DebugLog.Enabled = true;

if (ansiConsole == null)
{
throw new ArgumentException("ansiConsole cannot be null");
Expand All @@ -15,7 +17,14 @@ public SteamKitDebugListener(IAnsiConsole ansiConsole)

public void WriteLine(string category, string msg)
{
_ansiConsole.LogMarkupLine($"{category}: {msg}");
// Removing GUID that just pollutes the output
category = Regex.Replace(category, @"^[a-fA-F0-9]{32}/", string.Empty);

// Colorizing the CM url + removing the annoying unspecified prefix
msg = Regex.Replace(msg, @"(?:[a-zA-Z0-9\-]+)\.steamserver\.net", match => Cyan(match.Value));
msg = msg.Replace("Unspecified/", "");

_ansiConsole.LogMarkupLine($"{LightGreen(category)}: {msg}");
}
}
}
1 change: 1 addition & 0 deletions SteamPrefill/Properties/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
global using System.Threading;
global using System.Text.Json;
global using System.Text.Json.Serialization;
global using System.Text.RegularExpressions;
global using System.Threading.Tasks;
global using Terminal.Gui;
global using static LancachePrefill.Common.SpectreFormatters;
Expand Down
4 changes: 2 additions & 2 deletions SteamPrefill/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Prefill All": {
"commandName": "Project",
"commandLineArgs": "prefill --all --force --verbose"
"commandLineArgs": "prefill --debug --cellid 63"
},
"Prefill All - No Download": {
"commandName": "Project",
Expand All @@ -14,7 +14,7 @@
},
"Select Apps": {
"commandName": "Project",
"commandLineArgs": "select-apps"
"commandLineArgs": "select-apps --cellid 66"
},
"Prefill Selected": {
"commandName": "Project",
Expand Down
6 changes: 0 additions & 6 deletions SteamPrefill/SteamManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ public SteamManager(IAnsiConsole ansiConsole, DownloadArguments downloadArgs)
_ansiConsole = ansiConsole;
_downloadArgs = downloadArgs;

if (AppConfig.DebugLogs)
{
DebugLog.AddListener(new SteamKitDebugListener(_ansiConsole));
DebugLog.Enabled = true;
}

_steam3 = new Steam3Session(_ansiConsole);
_cdnPool = new CdnPool(_ansiConsole, _steam3);
_appInfoHandler = new AppInfoHandler(_ansiConsole, _steam3, _steam3.LicenseManager);
Expand Down

0 comments on commit ab7870e

Please sign in to comment.