Cut some code and determined the issue behind authenticated downloads not working. It's fixed now.

--HG--
extra : convert_revision : svn%3A946a0da7-ebce-4904-9acb-2f1e67aed693%40218
pull/8/head
Ryan Stecker 15 years ago
parent 14f2b6e39d
commit de9ea3a6c8

@ -14,6 +14,8 @@ namespace DepotDownloader
{ {
const string DOWNLOAD_DIR = "depots"; const string DOWNLOAD_DIR = "depots";
static Steam3Session steam3;
public static void Download( int depotId, int depotVersion, int cellId, string username, string password ) public static void Download( int depotId, int depotVersion, int cellId, string username, string password )
{ {
Directory.CreateDirectory( DOWNLOAD_DIR ); Directory.CreateDirectory( DOWNLOAD_DIR );
@ -55,6 +57,10 @@ namespace DepotDownloader
if ( storageId == uint.MaxValue ) if ( storageId == uint.MaxValue )
{ {
Console.WriteLine( "This depot requires valid user credentials and a license for this app" ); Console.WriteLine( "This depot requires valid user credentials and a license for this app" );
if ( steam3 != null )
steam3.Disconnect();
return; return;
} }
@ -126,6 +132,9 @@ namespace DepotDownloader
csClient.Disconnect(); csClient.Disconnect();
if ( steam3 != null )
steam3.Disconnect();
} }
static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password ) static ContentServerClient.Credentials GetCredentials( uint depotId, string username, string password )
@ -144,7 +153,7 @@ namespace DepotDownloader
byte[] serverTgt; byte[] serverTgt;
Blob accountRecord; Blob accountRecord;
Console.Write( "Logging in '{0}'... ", username ); Console.Write( "Logging '{0}' into Steam2... ", username );
AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord ); AuthServerClient.LoginResult result = asClient.Login( username, password, out clientTgt, out serverTgt, out accountRecord );
if ( result != AuthServerClient.LoginResult.LoggedIn ) if ( result != AuthServerClient.LoginResult.LoggedIn )
@ -153,7 +162,9 @@ namespace DepotDownloader
return null; return null;
} }
Steam3Session steam3 = new Steam3Session( Console.WriteLine( " Done!" );
steam3 = new Steam3Session(
new SteamUser.LogOnDetails() new SteamUser.LogOnDetails()
{ {
Username = username, Username = username,

@ -24,6 +24,8 @@ namespace DepotDownloader
SteamApps steamApps; SteamApps steamApps;
Thread callbackThread; Thread callbackThread;
ManualResetEvent credentialHandle;
bool bConnected;
DateTime connectTime; DateTime connectTime;
@ -43,7 +45,8 @@ namespace DepotDownloader
this.logonDetails = details; this.logonDetails = details;
this.credentials = new Credentials(); this.credentials = new Credentials();
this.credentialHandle = new ManualResetEvent( false );
this.bConnected = false;
this.steamClient = new SteamClient(); this.steamClient = new SteamClient();
@ -53,16 +56,22 @@ namespace DepotDownloader
this.callbackThread = new Thread( HandleCallbacks ); this.callbackThread = new Thread( HandleCallbacks );
this.callbackThread.Start(); this.callbackThread.Start();
Console.Write( "Connecting to Steam3..." );
this.connectTime = DateTime.Now; this.connectTime = DateTime.Now;
this.steamClient.Connect(); this.steamClient.Connect();
} }
public Credentials WaitForCredentials() public Credentials WaitForCredentials()
{ {
this.callbackThread.Join(); // no timespan as the thread will terminate itself this.credentialHandle.WaitOne();
return credentials; return credentials;
} }
public void Disconnect()
{
steamClient.Disconnect();
}
void HandleCallbacks() void HandleCallbacks()
{ {
@ -72,7 +81,10 @@ namespace DepotDownloader
TimeSpan diff = DateTime.Now - connectTime; TimeSpan diff = DateTime.Now - connectTime;
if ( diff > STEAM3_TIMEOUT || ( credentials.HasSessionToken && credentials.AppTicket != null ) ) if ( diff > STEAM3_TIMEOUT && !bConnected )
break;
if ( credentials.HasSessionToken && credentials.AppTicket != null )
break; break;
if ( callback == null ) if ( callback == null )
@ -80,7 +92,14 @@ namespace DepotDownloader
if ( callback.IsType<SteamClient.ConnectCallback>() ) if ( callback.IsType<SteamClient.ConnectCallback>() )
{ {
Console.WriteLine( " Done!" );
bConnected = true;
steamUser.LogOn( logonDetails ); steamUser.LogOn( logonDetails );
SteamID steamId = new SteamID();
steamId.SetFromSteam2( logonDetails.ClientTGT.UserID, steamClient.ConnectedUniverse );
Console.Write( "Logging '{0}' into Steam3...", steamId.Render() );
} }
if ( callback.IsType<SteamUser.LogOnCallback>() ) if ( callback.IsType<SteamUser.LogOnCallback>() )
@ -94,6 +113,8 @@ namespace DepotDownloader
break; break;
} }
Console.WriteLine( " Done!" );
steamApps.GetAppOwnershipTicket( depotId ); steamApps.GetAppOwnershipTicket( depotId );
} }
@ -111,6 +132,7 @@ namespace DepotDownloader
break; break;
} }
Console.WriteLine( "Got appticket for {0}!", depotId );
credentials.AppTicket = msg.Ticket; credentials.AppTicket = msg.Ticket;
} }
@ -119,12 +141,15 @@ namespace DepotDownloader
{ {
var msg = callback as SteamUser.SessionTokenCallback; var msg = callback as SteamUser.SessionTokenCallback;
Console.WriteLine( "Got session token!" );
credentials.SessionToken = msg.SessionToken; credentials.SessionToken = msg.SessionToken;
credentials.HasSessionToken = true; credentials.HasSessionToken = true;
} }
} }
steamClient.Disconnect(); credentialHandle.Set();
} }
} }
} }

Loading…
Cancel
Save