private void OnVACStatus(SteamApps.VACStatusCallback callback) { if (callback.BannedApps.Contains(730)) { Console.WriteLine($"Banned: {username}"); steamUser.LogOff(); } }
private Task UpdateSteamThread() { return(Task.Run(async() => { while (isRunning) { try { callbacks.RunCallbacks(); } catch (Exception ex) { Console.Error.WriteLine(ex); } await Task.Delay(50).ConfigureAwait(false); } if (steamUser.SteamID != null) { steamUser.LogOff(); } Client.Disconnect(); })); }
/// <summary> /// Disconnects from the Steam network /// </summary> public void Disconnect() { user.LogOff(); client.Disconnect(); SteamInstances.RemoveInstance(username); }
static void OnLoggedOn(SteamUser.LoggedOnCallback callback) { if (callback.Result != EResult.OK) { if (callback.Result == EResult.AccountLogonDenied) { // if we recieve AccountLogonDenied or one of it's flavors (AccountLogonDeniedNoMailSent, etc) // then the account we're logging into is SteamGuard protected // see sample 5 for how SteamGuard can be handled Console.WriteLine("Unable to logon to Steam: This account is SteamGuard protected."); isRunning = false; return; } 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 // for this sample we'll just log off steamUser.LogOff(); }
static void OnMethodResponse(SteamUnifiedMessages.ServiceMethodResponse callback) { if (callback.JobID != badgeRequest) { // always double check the jobid of the response to ensure you're matching to your original request return; } // and check for success if (callback.Result != EResult.OK) { Console.WriteLine($"Unified service request failed with {callback.Result}"); return; } // retrieve the deserialized response for the request we made // notice the naming pattern // for requests: CMyService_Method_Request // for responses: CMyService_Method_Response CPlayer_GetGameBadgeLevels_Response resp = callback.GetDeserializedResponse <CPlayer_GetGameBadgeLevels_Response>(); Console.WriteLine($"Our player level is {resp.player_level}"); foreach (var badge in resp.badges) { Console.WriteLine($"Badge series {badge.series} is level {badge.level}"); } badgeRequest = JobID.Invalid; // now that we've completed our task, lets log off steamUser.LogOff(); }
public override void Stop() { _reportInfo = null; _commendInfo = null; _liveGameInfo = null; if (_steamFriends.GetPersonaState() != EPersonaState.Offline) { _steamFriends.SetPersonaState(EPersonaState.Offline); } if (_steamUser.SteamID != null) { _steamUser.LogOff(); } if (_steamClient.IsConnected) { _steamClient.Disconnect(); } IsRunning = false; Titan.Instance.ThreadManager.FinishBotting(this); }
/// <summary> /// We want to stop the bot, therefore we have to logout and disconnect from steam /// </summary> public void Stop() { m_keepRunning = false; m_disconnectRequested = true; m_logger.Warning($"Stopping Bot"); m_steamUser.LogOff(); m_steamClient.Disconnect(); }
public static void Logout() { user = null; isRunning = false; IsLoggedIn = false; steamUser.LogOff(); CurrentPersonaState = 0; CurrentUsername = null; }
public void Disconnect(bool sendLogOff = true) { if (sendLogOff) { steamUser.LogOff(); } steamClient.Disconnect(); bConnected = false; }
public void Disconnect(bool tryReconnect = false) { IsRunning = false; SteamUser.LogOff(); SteamClient.Disconnect(); if (tryReconnect) { _login.Connect(); } }
/// <summary> /// Cleans up allocated resources. /// </summary> public void Dispose() { _user.LogOff(); callbacksTask.Wait(); _onLoginKey.Dispose(); _onLoggedOn.Dispose(); _onMachineAuth.Dispose(); _onConnected.Dispose(); _onDisconnected.Dispose(); _authTicket.Dispose(); cts.Dispose(); }
public void Disconnect() { isConnected = false; isRunning = false; if (steamFriends.GetPersonaState() != EPersonaState.Offline) { steamFriends.SetPersonaState(EPersonaState.Offline); } steamUser.LogOff(); steamClient.Disconnect(); }
public static void Main() { Console.Title = "SteamToTwitter"; Log("Starting..."); Console.CancelKeyPress += delegate { Log("Exiting..."); try { User.LogOff(); Client.Disconnect(); } catch { Log("Failed to disconnect from Steam"); } IsRunning = false; }; Configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText("settings.json"), new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); Twitter = new TinyTwitter.TinyTwitter(Configuration.Twitter); var callbackManager = new CallbackManager(Client); callbackManager.Subscribe <SteamClient.ConnectedCallback>(OnConnected); callbackManager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected); callbackManager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn); callbackManager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff); callbackManager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachineAuth); callbackManager.Subscribe <SteamUser.AccountInfoCallback>(OnAccountInfo); callbackManager.Subscribe <SteamFriends.ClanStateCallback>(OnClanState); Client.Connect(); var reconnectTime = TimeSpan.FromHours(6); new Timer(_ => Client.Disconnect(), null, reconnectTime, reconnectTime); while (IsRunning) { callbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(5)); } }
/// <summary> /// Make sure every client is shutdown completely /// </summary> private void ReleaseSteamConnection() { ReleaseDotaGCConnection(); SteamFriends?.SetPersonaState(EPersonaState.Offline); SteamFriends = null; SteamUser?.LogOff(); SteamUser = null; SteamClient?.Disconnect(); SteamClient = null; _cbThreadCtr++; }
public void Disconnect(bool sendLogOff = true) { if (sendLogOff) { steamUser.LogOff(); } steamClient.Disconnect(); bConnected = false; bConnecting = false; bAborted = true; // flush callbacks callbacks.RunCallbacks(); }
public void Disconnect() { stop = true; steamUser.LogOff(); steamClient.Disconnect(); CancelTradeOfferPollingThread(); botThread.CancelAsync(); while (botThread.IsBusy) { Thread.Yield(); } Console.WriteLine("stopping bot {0} ...", Name); }
static void OnLoggedOn(SteamUser.LoggedOnCallback callback) { 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 // for this sample we'll just log off steamUser.LogOff(); }
public void Disconnect(bool sendLogOff = true) { if (sendLogOff) { steamUser.LogOff(); } steamClient.Disconnect(); bConnected = false; bConnecting = false; bAborted = true; // flush callbacks until our disconnected event while (!bDidDisconnect) { callbacks.RunWaitAllCallbacks(TimeSpan.FromMilliseconds(100)); } }
internal async Task Stop() { isManualDisconnect = true; initialized = false; Log("Disconnecting from steam...", LogType.Info); if (steamUser.SteamID != null) { steamUser.LogOff(); } steamClient.Disconnect(); /* Farming cleaning */ foreach (var game in CurrentFarming) { game.StopIdle(); } CurrentFarming.Clear(); FarmTimerStop(); SteamCheckCancel.Cancel(); }
protected virtual void Dispose(bool disposing) { if (disposing) { // Stop thread if it is running if (_ThreadRunning) { _ThreadRunning = false; } Ready = false; // Disconnect from Steam3 _User.LogOff(); if (_Client.IsConnected) { _Client.Disconnect(); } } }
public override void Stop() { if (_steamFriends.GetPersonaState() == EPersonaState.Online) { _steamFriends.SetPersonaState(EPersonaState.Offline); } if (_steamUser.SteamID != null) { _steamUser.LogOff(); } if (_steamClient.IsConnected) { _steamClient.Disconnect(); } IsRunning = false; }
private void GetBanned() { Console.WriteLine("[Steam] Checking Account if Banned" + "\n"); account_status.Text = "Loading..."; account_status.ForeColor = Color.Blue; steamClient = new SteamClient(); manager = new CallbackManager(steamClient); steamUser = steamClient.GetHandler <SteamUser>(); manager.Subscribe <SteamClient.ConnectedCallback>(OnConnected); manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected); manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn); manager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff); isRunning = true; Console.WriteLine("[Steam] Connecting to Steam..." + "\n"); // initiate the connection steamClient.Connect(); // 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)); } if (File.Exists(appDataPath + @"\data.json")) { var creds = File.ReadAllText(appDataPath + @"\data.json").Split(Convert.ToChar(",")); var data = JsonConvert.DeserializeObject <dataJson>(EncryptProvider.AESDecrypt(creds[2], creds[0], creds[1])); } else { MessageBox.Show("Please set your settings\nthis menu will now close", "Error"); steamUser.LogOff(); steamClient.Disconnect(); this.Close(); } }
static void OnLoggedOn(SteamUser.LoggedOnCallback callback) { if (callback.Result != EResult.OK) { if (callback.Result == EResult.AccountLogonDenied) { Console.WriteLine("Steam Guard protected"); isRunning = false; Console.ReadLine(); } Console.WriteLine("Login failed"); isRunning = false; Console.ReadLine(); } else { Console.WriteLine("Login successful"); steamUser.LogOff(); Console.ReadLine(); } }
static void OnLoggedOn(SteamUser.LoggedOnCallback callback) { bool isSteamGuard = callback.Result == EResult.AccountLogonDenied; bool is2FA = callback.Result == EResult.AccountLoginDeniedNeedTwoFactor; if (isSteamGuard || is2FA) { Console.WriteLine("Unable to logon to Steam: 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!"); PickRandomInstalledGame(); steamUser.LogOff(); return; }
static async void OnLoggedOn( SteamUser.LoggedOnCallback callback ) { if ( callback.Result != EResult.OK ) { Console.WriteLine( "Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult ); m_isRunning = false; return; } Console.WriteLine( "Successfully logged on!" ); Console.WriteLine( $"Looking up clienticon for {m_appid}" ); var productInfo = await m_steamApps.PICSGetProductInfo( m_appid, null ); var hash = productInfo.Results[ 0 ].Apps[ m_appid ].KeyValues[ "common" ][ "clienticon" ].Value; Console.WriteLine( $"Got hash ${hash}" ); var resp = await m_http.GetAsync( $"http://media.steampowered.com/steamcommunity/public/images/apps/{m_appid}/{hash}.ico?original=1" ); using ( var fs = new FileStream( $"{m_appid}.ico", FileMode.OpenOrCreate ) ) await resp.Content.CopyToAsync( fs ); m_steamUser.LogOff(); }
public override void Stop() { _reportInfo = null; _commendInfo = null; _liveGameInfo = null; if (_steamFriends.GetPersonaState() != EPersonaState.Offline) { _steamFriends.SetPersonaState(EPersonaState.Offline); } if (_steamUser.SteamID != null) { _steamUser.LogOff(); } if (_steamClient.IsConnected) { _steamClient.Disconnect(); } IsRunning = false; }
static void FullyLoggedIn(SteamUser.LoggedOnCallback callback) { var task = Task.Run(async() => { try { await CloudStream.DeleteFile("gmpublish_icon.jpg", APPID, steamClient); await CloudStream.DeleteFile("gmpublish.gma", APPID, steamClient); var baseFolder = "./Addon"; var gmaPath = "./addon.gma"; //Path.GetTempFileName(); var addonJsonPath = Path.Combine(baseFolder, "addon.json"); if (!File.Exists(addonJsonPath)) { throw new Exception("No addon.json file found in specified folder"); } AddonJSON addon; using (FileStream addonStream = new FileStream(addonJsonPath, FileMode.Open)) { addon = addonStream.CreateFromJsonStream <AddonJSON>(); } if (addon.Icon == "") { throw new Exception("No icon file specified"); } using (Stream gmaStream = new FileStream(gmaPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None)) { GMADCreator.Create(baseFolder, addon, gmaStream); gmaStream.Seek(0, SeekOrigin.Begin); using (var icon = new FileStream(Path.Combine(baseFolder, addon.Icon), FileMode.Open)) { var hash = SHAHash(icon); var iconSuccess = await CloudStream.UploadStream("gmpublish_icon.jpg", APPID, hash, icon.Length, steamClient, icon); if (!iconSuccess) { Console.WriteLine("JPG Upload failed"); return; } } var lzmaStream = LZMAEncodeStream.CompressStreamLZMA(gmaStream); var hashGma = SHAHash(lzmaStream); var gmaSuccess = await CloudStream.UploadStream("gmpublish.gma", APPID, hashGma, lzmaStream.Length, steamClient, lzmaStream); if (!gmaSuccess) { Console.WriteLine("GMA Upload failed"); return; } } var publishService = steamUnifiedMessages.CreateService <IPublishedFile>(); if (addon.WorkshopID == 0) { var request = new CPublishedFile_Publish_Request { appid = APPID, consumer_appid = APPID, cloudfilename = "gmpublish.gma", preview_cloudfilename = "gmpublish_icon.jpg", title = addon.Title, file_description = addon.Description, file_type = (uint)EWorkshopFileType.Community, visibility = (uint)EPublishedFileVisibility.Public, collection_type = addon.Type, }; foreach (var tag in addon.Tags) { request.tags.Add(tag); } var publishCallback = await publishService.SendMessage(publish => publish.Publish(request)); var publishResponse = publishCallback.GetDeserializedResponse <CPublishedFile_Publish_Response>(); addon.WorkshopID = publishResponse.publishedfileid; using (FileStream addonStream = new FileStream(addonJsonPath, FileMode.Create)) { addonStream.WriteObjectToStreamJson(addon); } Console.WriteLine("NEW PUBLISHED ID: " + publishResponse.publishedfileid + ". Wrote to addon.json"); } else { var request = new CPublishedFile_Update_Request { image_height = 512, image_width = 512, publishedfileid = addon.WorkshopID, appid = APPID, filename = "gmpublish.gma", preview_filename = "gmpublish_icon.jpg", title = addon.Title, file_description = addon.Description, visibility = (uint)EPublishedFileVisibility.Public, }; foreach (var tag in addon.Tags) { request.tags.Add(tag); } var updateCallback = await publishService.SendMessage(publish => publish.Update(request)); var updateResponse = updateCallback.GetDeserializedResponse <CPublishedFile_Update_Response>(); Console.WriteLine("Addon has been updated"); } } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }); task.Wait(); steamUser.LogOff(); isRunning = false; }
// Tells the steam interface to log off public void Logoff() { UpdateUILabel("Logging off"); steamUser?.LogOff(); }
public void Logout() { user.LogOff(); client.Disconnect(); NotifyDisconnected(); }
static void Main(string[] args) { if (args.Length < 2) { Console.WriteLine("Sample7: No username and password specified!"); return; } // save our logon details user = args[0]; pass = args[1]; // create our steamclient instance steamClient = new SteamClient(); // create the callback manager which will route callbacks to function calls manager = new CallbackManager(steamClient); // get the steamuser handler, which is used for logging on after successfully connecting 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); Console.CancelKeyPress += (s, e) => { e.Cancel = true; Console.WriteLine("Received {0}, disconnecting...", e.SpecialKey); steamUser.LogOff(); }; var cellid = 0u; // if we've previously connected and saved our cellid, load it. if (File.Exists("cellid.txt")) { if (!uint.TryParse(File.ReadAllText("cellid.txt"), out cellid)) { Console.WriteLine("Error parsing cellid from cellid.txt. Continuing with cellid 0."); } else { Console.WriteLine($"Using persisted cell ID {cellid}"); } } SteamClient.Servers.CellID = cellid; SteamClient.Servers.ServerListProvider = new FileStorageServerListProvider("servers_list.bin"); isRunning = true; Console.WriteLine("Connecting to Steam..."); // initiate the connection steamClient.Connect(); // 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)); } }