You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys! Using code from example, but its not working :/
I don't get any callback and code stuck in while cycle
` var user = "*";
var pass = "";
string authCode = null, twoFactorAuth = null;
// create our steamclient instance
var steamClient = new SteamClient();
// create the callback manager which will route callbacks to function calls
var manager = new CallbackManager(steamClient);
// get the steamuser handler, which is used for logging on after successfully connecting
var steamUser = steamClient.GetHandler<SteamUser>();
// register a few callbacks we're interested in
// these are registered upon creation to a callback manager, which will then route the callbacks
// to the functions specified
manager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
manager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
// this callback is triggered when the steam servers wish for the client to store the sentry file
manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
var isRunning = true;
Console.WriteLine("Connecting to Steam...");
// initiate the connection
steamClient.Connect();
Console.WriteLine();
// create our callback handling loop
while (isRunning)
{
// in order for the callbacks to get routed, they need to be handled by the manager
manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
}
void OnConnected(SteamClient.ConnectedCallback callback)
{
Console.WriteLine("Connected to Steam! Logging in '{0}'...", user);
byte[] sentryHash = null;
if (File.Exists("sentry.bin"))
{
// if we have a saved sentry file, read and sha-1 hash it
byte[] sentryFile = File.ReadAllBytes("sentry.bin");
sentryHash = CryptoHelper.SHAHash(sentryFile);
}
steamUser.LogOn(new SteamUser.LogOnDetails
{
Username = user,
Password = pass,
// in this sample, we pass in an additional authcode
// this value will be null (which is the default) for our first logon attempt
AuthCode = authCode,
// if the account is using 2-factor auth, we'll provide the two factor code instead
// this will also be null on our first logon attempt
TwoFactorCode = twoFactorAuth,
// our subsequent logons use the hash of the sentry file as proof of ownership of the file
// this will also be null for our first (no authcode) and second (authcode only) logon attempts
SentryFileHash = sentryHash,
});
}
void OnDisconnected(SteamClient.DisconnectedCallback callback)
{
// after recieving an AccountLogonDenied, we'll be disconnected from steam
// so after we read an authcode from the user, we need to reconnect to begin the logon flow again
Console.WriteLine("Disconnected from Steam, reconnecting in 5...");
Thread.Sleep(TimeSpan.FromSeconds(5));
steamClient.Connect();
}
void OnLoggedOn(SteamUser.LoggedOnCallback callback)
{
bool isSteamGuard = callback.Result == EResult.AccountLogonDenied;
bool is2FA = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor;
if (isSteamGuard || is2FA)
{
Console.WriteLine("This account is SteamGuard protected!");
if (is2FA)
{
Console.Write("Please enter your 2 factor auth code from your authenticator app: ");
twoFactorAuth = Console.ReadLine();
}
else
{
Console.Write("Please enter the auth code sent to the email at {0}: ", callback.EmailDomain);
authCode = Console.ReadLine();
}
return;
}
if (callback.Result != EResult.OK)
{
Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);
isRunning = false;
return;
}
Console.WriteLine("Successfully logged on!");
// at this point, we'd be able to perform actions on Steam
}
void OnLoggedOff(SteamUser.LoggedOffCallback callback)
{
Console.WriteLine("Logged off of Steam: {0}", callback.Result);
}
void OnMachineAuth(SteamUser.UpdateMachineAuthCallback callback)
{
Console.WriteLine("Updating sentryfile...");
// write out our sentry file
// ideally we'd want to write to the filename specified in the callback
// but then this sample would require more code to find the correct sentry file to read during logon
// for the sake of simplicity, we'll just use "sentry.bin"
int fileSize;
byte[] sentryHash;
using (var fs = File.Open("sentry.bin", FileMode.OpenOrCreate, FileAccess.ReadWrite))
{
fs.Seek(callback.Offset, SeekOrigin.Begin);
fs.Write(callback.Data, 0, callback.BytesToWrite);
fileSize = (int)fs.Length;
fs.Seek(0, SeekOrigin.Begin);
var sha = SHA1.Create();
sentryHash = sha.ComputeHash(fs);
}
// inform the steam servers that we're accepting this sentry file
steamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails
{
JobID = callback.JobID,
FileName = callback.FileName,
BytesWritten = callback.BytesToWrite,
FileSize = fileSize,
Offset = callback.Offset,
Result = EResult.OK,
LastError = 0,
OneTimePassword = callback.OneTimePassword,
SentryFileHash = sentryHash,
});
Console.WriteLine("Done!");`
What im doing wrong? Pls help me, its my first time working with this library :(
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi guys! Using code from example, but its not working :/
I don't get any callback and code stuck in while cycle
` var user = "*";
var pass = "";
What im doing wrong? Pls help me, its my first time working with this library :(
Beta Was this translation helpful? Give feedback.
All reactions