コード例 #1
0
        /// <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)
        {
            if (details == null)
            {
                throw new ArgumentNullException(nameof(details));
            }

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

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

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

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

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = (uint)details.ClientOSType;
            logon.Body.client_language  = details.ClientLanguage;
            logon.Body.cell_id          = details.CellID;

            logon.Body.machine_id = HardwareUtils.GetMachineID();

            this.Client.Send(logon);
        }
コード例 #2
0
        /// <summary>
        /// Logs the client into the Steam3 network as an anonymous game server.
        /// The client should already have been connected at this point.
        /// Results are returned in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="appId">The AppID served by this game server, or 0 for the default.</param>
        public void LogOnAnonymous(uint appId = 0)
        {
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new SteamUser.LoggedOnCallback(EResult.NoConnection));
                return;
            }

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

            SteamID gsId = new SteamID(0, 0, Client.Universe, EAccountType.AnonGameServer);

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

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

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

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )appId;
            logon.Body.machine_id         = HardwareUtils.GetMachineID();

            this.Client.Send(logon);
        }
コード例 #3
0
ファイル: SteamClient.cs プロジェクト: umaim/SteamKit
        /// <summary>
        /// Initializes a new instance of the <see cref="SteamClient"/> class with a specific configuration and identifier
        /// </summary>
        /// <param name="configuration">The configuration to use for this client.</param>
        /// <param name="identifier">A specific identifier to be used to uniquely identify this instance.</param>
        /// <exception cref="ArgumentNullException">The configuration object or identifier is <c>null</c></exception>
        /// <exception cref="ArgumentException">The identifier is an empty string</exception>
        public SteamClient(SteamConfiguration configuration, string identifier)
            : base(configuration, identifier)
        {
            callbackQueue = new Queue <ICallbackMsg>();

            this.handlers = new OrderedDictionary();

            // Start calculating machine info so that it is (hopefully) ready by the time we get to logging in.
            HardwareUtils.Init(configuration.MachineInfoProvider);

            // add this library's handlers
            // notice: SteamFriends should be added before SteamUser due to AccountInfoCallback
            this.AddHandler(new SteamFriends());
            this.AddHandler(new SteamUser());
            this.AddHandler(new SteamApps());
            this.AddHandler(new SteamGameCoordinator());
            this.AddHandler(new SteamGameServer());
            this.AddHandler(new SteamUserStats());
            this.AddHandler(new SteamMasterServer());
            this.AddHandler(new SteamCloud());
            this.AddHandler(new SteamWorkshop());
            this.AddHandler(new SteamTrading());
            this.AddHandler(new SteamUnifiedMessages());
            this.AddHandler(new SteamScreenshots());
            this.AddHandler(new SteamMatchmaking());
            this.AddHandler(new SteamNetworking());
            this.AddHandler(new SteamContent());

            using (var process = Process.GetCurrentProcess())
            {
                this.processStartTime = process.StartTime;
            }

            dispatchMap = new Dictionary <EMsg, Action <IPacketMsg> >
            {
                { EMsg.ClientCMList, HandleCMList },

                // to support asyncjob life time
                { EMsg.JobHeartbeat, HandleJobHeartbeat },
                { EMsg.DestJobFailed, HandleJobFailed },
            };

            jobManager = new AsyncJobManager();
        }
コード例 #4
0
        /// <summary>
        /// Logs onto the Steam network as a persistent game server.
        /// The client should already have been connected at this point.
        /// Results are return in a <see cref="SteamUser.LoggedOnCallback"/>.
        /// </summary>
        /// <param name="details">The details to use for logging on.</param>
        /// <exception cref="System.ArgumentNullException">No logon details were provided.</exception>
        /// <exception cref="System.ArgumentException">Username or password are not set within <paramref name="details"/>.</exception>
        public void LogOn(LogOnDetails details)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }

            if (string.IsNullOrEmpty(details.Token))
            {
                throw new ArgumentException("LogOn requires a game server token to be set in 'details'.");
            }

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

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

            SteamID gsId = new SteamID(0, 0, Client.Universe, EAccountType.GameServer);

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

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

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

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;

            logon.Body.client_os_type     = ( uint )Utils.GetOSType();
            logon.Body.game_server_app_id = ( int )details.AppID;
            logon.Body.machine_id         = HardwareUtils.GetMachineID();

            logon.Body.game_server_token = details.Token;

            this.Client.Send(logon);
        }
コード例 #5
0
        /// <summary>
        /// Logs the client into the Steam3 network.
        /// 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>
        /// <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)
        {
            if (details == null)
            {
                throw new ArgumentNullException("details");
            }
            if (string.IsNullOrEmpty(details.Username) || (string.IsNullOrEmpty(details.Password) && string.IsNullOrEmpty(details.LoginKey)))
            {
                throw new ArgumentException("LogOn requires a username and password to be set in 'details'.");
            }
            if (!string.IsNullOrEmpty(details.LoginKey) && !details.ShouldRememberPassword)
            {
                // Prevent consumers from screwing this up.
                // If should_remember_password is false, the login_key is ignored server-side.
                // The inverse is not applicable (you can log in with should_remember_password and no login_key).
                throw new ArgumentException("ShouldRememberPassword is required to be set to true in order to use LoginKey.");
            }
            if (!this.Client.IsConnected)
            {
                this.Client.PostCallback(new LoggedOnCallback(EResult.NoConnection));
                return;
            }

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

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

            if (details.LoginID.HasValue)
            {
                logon.Body.obfustucated_private_ip = details.LoginID.Value;
            }
            else
            {
                uint localIp = NetHelpers.GetIPAddress(this.Client.LocalIP);
                logon.Body.obfustucated_private_ip = localIp ^ MsgClientLogon.ObfuscationMask;
            }

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

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

            logon.Body.protocol_version = MsgClientLogon.CurrentProtocol;
            logon.Body.client_os_type   = ( uint )details.ClientOSType;
            logon.Body.client_language  = details.ClientLanguage;
            logon.Body.cell_id          = details.CellID;

            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
            logon.Body.machine_id             = HardwareUtils.GetMachineID();

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

            logon.Body.login_key = details.LoginKey;

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


            this.Client.Send(logon);
        }
コード例 #6
0
 static SteamUser()
 {
     HardwareUtils.Init();
 }
コード例 #7
0
 public static string GenerateRandomMachineID() => HardwareUtils.GenerateRandomMachineID();