Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow awaiting LogOn #1461

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SteamKit2/SteamKit2/Steam/Handlers/SteamUser/Callbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ internal LoggedOnCallback( IPacketMsg packetMsg )
var logonResp = new ClientMsgProtobuf<CMsgClientLogonResponse>( packetMsg );
var resp = logonResp.Body;

this.JobID = logonResp.TargetJobID;
this.Result = ( EResult )resp.eresult;
this.ExtendedResult = ( EResult )resp.eresult_extended;

Expand Down Expand Up @@ -161,6 +162,7 @@ private void HandleNonProtoLogon( IPacketMsg packetMsg )
var logonResp = new ClientMsg<MsgClientLogOnResponse>( packetMsg );
var resp = logonResp.Body;

this.JobID = logonResp.TargetJobID;
this.Result = resp.Result;

this.OutOfGameSecsPerHeartbeat = resp.OutOfGameHeartbeatRateSec;
Expand Down Expand Up @@ -197,11 +199,13 @@ internal LoggedOffCallback( IPacketMsg packetMsg )
if ( packetMsg.IsProto )
{
var loggedOff = new ClientMsgProtobuf<CMsgClientLoggedOff>( packetMsg );
this.JobID = loggedOff.TargetJobID;
this.Result = ( EResult )loggedOff.Body.eresult;
}
else
{
var loggedOff = new ClientMsg<MsgClientLoggedOff>( packetMsg );
this.JobID = loggedOff.TargetJobID;
this.Result = loggedOff.Body.Result;
}
}
Expand Down
28 changes: 18 additions & 10 deletions SteamKit2/SteamKit2/Steam/Handlers/SteamUser/SteamUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ public SteamID? SteamID
/// <param name="details">The details to use for logging on.</param>
/// <exception cref="ArgumentNullException">No logon details were provided.</exception>
/// <exception cref="ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
public void LogOn( LogOnDetails details )
/// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="LoggedOnCallback"/>.</returns>
public AsyncJob<LoggedOnCallback> LogOn( LogOnDetails details )
{
ArgumentNullException.ThrowIfNull( details );

Expand All @@ -231,14 +232,14 @@ public void LogOn( LogOnDetails details )
throw new ArgumentException( "LogOn requires a username and password or access token to be set in 'details'." );
}

var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

if ( !this.Client.IsConnected )
{
this.Client.PostCallback( new LoggedOnCallback( EResult.NoConnection ) );
return;
return new AsyncJob<LoggedOnCallback>( this.Client, logon.SourceJobID );
}

var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

SteamID steamId = new SteamID( details.AccountID, details.AccountInstance, Client.Universe, EAccountType.Individual );

if ( details.LoginID.HasValue )
Expand Down Expand Up @@ -302,34 +303,39 @@ public void LogOn( LogOnDetails details )
logon.Body.access_token = details.AccessToken;

this.Client.Send( logon );

return new AsyncJob<LoggedOnCallback>( this.Client, logon.SourceJobID );
}

/// <summary>
/// Logs the client into the Steam3 network as an anonymous user.
/// The client should already have been connected at this point.
/// Results are returned in a <see cref="LoggedOnCallback"/>.
/// </summary>
public void LogOnAnonymous()
/// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="LoggedOnCallback"/>.</returns>
public AsyncJob<LoggedOnCallback> LogOnAnonymous()
{
LogOnAnonymous( new AnonymousLogOnDetails() );
return LogOnAnonymous( new AnonymousLogOnDetails() );
}
/// <summary>
/// Logs the client into the Steam3 network as an anonymous user.
/// The client should already have been connected at this point.
/// Results are returned in a <see cref="LoggedOnCallback"/>.
/// </summary>
/// <param name="details">The details to use for logging on.</param>
public void LogOnAnonymous( AnonymousLogOnDetails details )
/// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="LoggedOnCallback"/>.</returns>
public AsyncJob<LoggedOnCallback> LogOnAnonymous( AnonymousLogOnDetails details )
{
ArgumentNullException.ThrowIfNull( details );

var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );

if ( !this.Client.IsConnected )
{
this.Client.PostCallback( new LoggedOnCallback( EResult.NoConnection ) );
return;
}

var logon = new ClientMsgProtobuf<CMsgClientLogon>( EMsg.ClientLogon );
return new AsyncJob<LoggedOnCallback>( this.Client, logon.SourceJobID );
}

SteamID auId = new SteamID( 0, 0, Client.Universe, EAccountType.AnonUser );

Expand All @@ -344,6 +350,8 @@ public void LogOnAnonymous( AnonymousLogOnDetails details )
logon.Body.machine_id = HardwareUtils.GetMachineID( Client.Configuration.MachineInfoProvider );

this.Client.Send( logon );

return new AsyncJob<LoggedOnCallback>( this.Client, logon.SourceJobID );
}

/// <summary>
Expand Down
Loading