예제 #1
0
        public SteamClient(SteamCredentials credentials, SteamAuthenticationCodesProvider codesProvider, SteamAuthenticationFilesProvider authenticationProvider)
        {
            Credentials             = credentials ?? throw new ArgumentNullException(nameof(credentials));
            _codesProvider          = codesProvider;
            _authenticationProvider = authenticationProvider;
            InternalClient          = new SteamKit.SteamClient();

            _cancellationTokenSource = new CancellationTokenSource();
            CallbackManager          = new SteamKit.CallbackManager(InternalClient);

            _steamUser = InternalClient.GetHandler <SteamKit.SteamUser>();
            _steamApps = InternalClient.GetHandler <SteamKit.SteamApps>();

            Task.Run(async() => await CallbackManagerHandler());

            CallbackManager.Subscribe <SteamKit.SteamClient.ConnectedCallback>(OnConnected);
            CallbackManager.Subscribe <SteamKit.SteamClient.DisconnectedCallback>(OnDisconnected);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOnCallback>(OnLoggedOn);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOffCallback>(OnLoggedOff);
            CallbackManager.Subscribe <SteamKit.SteamApps.LicenseListCallback>(OnLicenseList);
            CallbackManager.Subscribe <SteamKit.SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoginKeyCallback>(OnLoginKey);

            InternalClient.Connect();
        }
        public override void SaveSentryFileContent(SteamCredentials steamCredentials, byte[] data)
        {
            string file = Path.Combine(_directory, $"sentry_{steamCredentials.Username}.bin");

            Directory.CreateDirectory(_directory);
            File.WriteAllBytes(file, data);
        }
        public override void SaveLoginKey(SteamCredentials steamCredentials, string loginKey)
        {
            string file = Path.Combine(_directory, $"sentry_{steamCredentials.Username}.key");

            Directory.CreateDirectory(_directory);
            File.WriteAllText(file, loginKey);
        }
        public override byte[] GetSentryFileContent(SteamCredentials steamCredentials)
        {
            string file = Path.Combine(_directory, $"sentry_{steamCredentials.Username}.bin");

            if (!File.Exists(file))
            {
                return(null);
            }
            else
            {
                return(File.ReadAllBytes(file));
            }
        }
        public override string GetLoginKey(SteamCredentials steamCredentials)
        {
            string file = Path.Combine(_directory, $"sentry_{steamCredentials.Username}.key");

            if (!File.Exists(file))
            {
                return(null);
            }
            else
            {
                return(File.ReadAllText(file));
            }
        }
 public abstract string GetEmailAuthenticationCode(SteamCredentials steamCredentials);
 public abstract string GetTwoFactorAuthenticationCode(SteamCredentials steamCredentials);
 public override string GetTwoFactorAuthenticationCode(SteamCredentials steamCredentials) => null;
 public override string GetEmailAuthenticationCode(SteamCredentials steamCredentials) => null;
 public abstract void SaveSentryFileContent(SteamCredentials steamCredentials, byte[] data);
 public abstract void SaveLoginKey(SteamCredentials steamCredentials, string loginKey);
 public override void SaveSentryFileContent(SteamCredentials steamCredentials, byte[] data)
 {
     _sentryFileData.AddOrUpdate(steamCredentials.Username, key => data, (key, existingValue) => data);
 }
 public override void SaveLoginKey(SteamCredentials steamCredentials, string loginKey)
 {
     _loginKeys.AddOrUpdate(steamCredentials.Username, key => loginKey, (key, existingValue) => loginKey);
 }
 public override byte[] GetSentryFileContent(SteamCredentials steamCredentials)
 {
     return(_sentryFileData.GetValueOrDefault(steamCredentials.Username, null));
 }
 public override string GetLoginKey(SteamCredentials steamCredentials)
 {
     return(_loginKeys.GetValueOrDefault(steamCredentials.Username, null));
 }
예제 #16
0
 public SteamClient(SteamCredentials credentials) : this(credentials, new DefaultSteamAuthenticationCodesProvider(), new DefaultSteamAuthenticationFilesProvider())
 {
 }
 public abstract byte[] GetSentryFileContent(SteamCredentials steamCredentials);
 public abstract string?GetLoginKey(SteamCredentials steamCredentials);