SteamKit2.SteamUser.LogOn C# (CSharp) Method

LogOn() public method

Logs the client into the Steam3 network. The client should already have been connected at this point. Results are returned in a LoggedOnCallback.
No logon details were provided. Username or password are not set within .
public LogOn ( LogOnDetails details ) : void
details LogOnDetails The details to use for logging on.
return void
        public void LogOn( LogOnDetails details )
        {
            if ( details == null )
            {
                throw new ArgumentNullException( "details" );
            }
            if ( string.IsNullOrEmpty( details.Username ) || string.IsNullOrEmpty( details.Password ) )
            {
                throw new ArgumentException( "LogOn requires a username and password to be set in 'details'." );
            }

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

            SteamID steamId = new SteamID( 0, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual );

            uint localIp = NetHelpers.GetIPAddress( this.Client.LocalIP );

            logon.ProtoHeader.client_sessionid = 0;
            logon.ProtoHeader.steamid = steamId.ConvertToUInt64();

            logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;

            logon.Body.account_name = details.Username;
            logon.Body.password = details.Password;

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type = ( uint )Utils.GetOSType();
            logon.Body.client_language = "english";

            logon.Body.steam2_ticket_request = details.RequestSteam2Ticket;

            // we're now using the latest steamclient package version, this is required to get a proper sentry file for steam guard
            logon.Body.client_package_version = 1771; // todo: determine if this is still required

            // this is not a proper machine id that Steam accepts
            // but it's good enough for identifying a machine
            logon.Body.machine_id = Utils.GenerateMachineID();


            // steam guard 
            logon.Body.auth_code = details.AuthCode;

            logon.Body.sha_sentryfile = details.SentryFileHash;
            logon.Body.eresult_sentryfile = ( int )( details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound );


            this.Client.Send( logon );
        }
        /// <summary>

Usage Example

Ejemplo n.º 1
0
        void OnConnected(SK.SteamClient.ConnectedCallback callback)
        {
            SK.SteamUser.LogOnDetails loginDetails = new SK.SteamUser.LogOnDetails
            {
                Username = Username,
                Password = Password
            };

            if (!string.IsNullOrWhiteSpace(AuthenticationCode))
            {
                loginDetails.AuthCode       = AuthenticationCode;
                loginDetails.TwoFactorCode  = AuthenticationCode;
                loginDetails.SentryFileHash = GetSentryHash();
            }

            steamUser.LogOn(loginDetails);

            Connected?.Invoke(this, null);
        }
All Usage Examples Of SteamKit2.SteamUser::LogOn