Skip to content

Commit

Permalink
🎨 support cancellationToken, steamService fixs
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzaz committed Dec 26, 2023
1 parent 8f6db14 commit 942bd98
Show file tree
Hide file tree
Showing 28 changed files with 719 additions and 539 deletions.
13 changes: 8 additions & 5 deletions src/BD.SteamClient8.Impl/PInvoke/SteamServiceImpl.Abstract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract partial class SteamServiceImpl
public abstract ISteamConnectService Conn { get; }

/// <inheritdoc/>
public virtual void StartSteamWithParameter() => StartSteam(StratSteamDefaultParameter);
public virtual Task<ApiRspImpl> StartSteamWithParameter(CancellationToken cancellationToken = default) => StartSteam(StratSteamDefaultParameter, cancellationToken);

/// <summary>
/// 以正常权限启动进程
Expand Down Expand Up @@ -165,18 +165,20 @@ public abstract partial class SteamServiceImpl
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static string GetLastSteamLoginUserName()
internal static string GetLastSteamLoginUserName(CancellationToken cancellationToken = default)
{
if (cancellationToken.IsCancellationRequested)
throw new OperationCanceledException();
#if WINDOWS
return Registry.CurrentUser.Read(SteamRegistryPath, "AutoLoginUser");
#else
return "";
#endif
}

/// <inheritdoc cref="ISteamService.SetSteamCurrentUserAsync(string)"/>
/// <inheritdoc cref="ISteamService.SetSteamCurrentUserAsync(string, CancellationToken)"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public virtual ValueTask SetSteamCurrentUserAsync(string userName)
public virtual async ValueTask<ApiRspImpl> SetSteamCurrentUserAsync(string userName, CancellationToken cancellationToken = default)
{
// override BD.WTTS.Services.Implementation.SteamServiceImpl2.SetSteamCurrentUser
#if WINDOWS
Expand Down Expand Up @@ -217,7 +219,8 @@ public virtual ValueTask SetSteamCurrentUserAsync(string userName)
Log.Error(TAG, e, "SetSteamCurrentUser fail(0).");
}
#endif
return ValueTask.CompletedTask;
await ValueTask.CompletedTask;
return ApiRspHelper.Ok();
}

#endif
Expand Down
Loading

0 comments on commit 942bd98

Please sign in to comment.