public bool Disconnect() { if (!LoggedIn) { return(false); } steamClient.Disconnect(); return(true); }
void doWork(object sender, DoWorkEventArgs e) { loop = true; while (true) { if (worker.CancellationPending) { loop = false; e.Cancel = true; client.Disconnect(); return; } try { cb.RunWaitCallbacks(TimeSpan.FromSeconds(5)); } catch (Exception ex) { Log(ex.Message, Color.Red); } try { var tray = getTray(txtProcess.Text); labelStatusBar.Text = tray.Replace("\n", "\\n").Replace("\r", "\\r"); if (tray.Length > 0) { var presence = Regex.Replace(tray, txtPattern.Text, txtRepl.Text); if (loggedIn) { if (presence != lastPresence) { friends.SetPersonaState(EPersonaState.Busy); var gamePlaying = new SteamKit2.ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed); gamePlaying.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(15190414816125648896), game_extra_info = presence }); client.Send(gamePlaying); lastPresence = presence; Log(presence, Color.LightPink); } } } } catch (Exception ex) { Log(ex.Message, Color.Red); } } }
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> /// Disconnects from the Steam network /// </summary> public void Disconnect() { user.LogOff(); client.Disconnect(); SteamInstances.RemoveInstance(username); }
public void LogOf() { Thread.Sleep(5000); _work = false; _client.Disconnect(); SteamServerList.ReleasServerRecord(_loginHandler.ServerRecord); }
/// <summary> /// Disconnect from the Steam network and stop the callback /// thread. /// </summary> public void StopBot() { log.Debug("Tryring to shut down bot thread."); SteamClient.Disconnect(); backgroundWorker.CancelAsync(); }
public void Stop() { _isRunning = SteamManagerStatus.Stopped; _steamClient.RemoveHandler(_steamFriends); _steamClient.RemoveHandler(_steamUser); _steamClient.Disconnect(); }
public void Disconnect() { waitForLastCallback.Reset(); m_steamClient.Disconnect(); waitForLastCallback.WaitOne(TimeSpan.FromSeconds(3));//give ManageCallbacks() 1 second to process the disconnect event. m_isRunning = false; }
/// <summary> /// Disconnect from the Steam network and stop the callback /// thread. /// </summary> public void StopBot() { System.Diagnostics.Debug.WriteLine("Tryring to shut down bot thread."); SteamClient.Disconnect(); backgroundWorker.CancelAsync(); }
static void Main(string[] args) { sclient.Connect(); CallbackMsg msg = sclient.GetCallback(); Type a = msg.GetType(); msg = sclient.GetCallback(); msg.ToString(); var asdf = (SteamUser.LoggedOnCallback)msg; if (asdf.Result == EResult.AccountLogonDenied) { Console.Write("Please enter the steam access code here: "); string steamaccesscode = Console.ReadLine(); sUser.LogOn(new SteamUser.LogOnDetails() { Username = username, Password = password, AuthCode = steamaccesscode }); msg = sclient.GetCallback(); asdf = (SteamUser.LoggedOnCallback)msg; } if (asdf.Result == EResult.OK) { sFriends.SendChatMessage(new SteamID("STEAM_0:1:16516144"), EChatEntryType.ChatMsg, "Fennecs :D"); Console.WriteLine(); Console.WriteLine("Logged in succesfully. Press any key to exit"); sclient.Disconnect(); } }
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 void Disconnect() { if (isRunning) { logger.Info("Disconnected"); steamClient.Disconnect(); } }
/// <summary> /// Disconnect from the Steam network and stop the callback /// thread. /// </summary> public void StopBot() { IsRunning = false; Log.Debug("Trying to shut down bot thread."); SteamClient.Disconnect(); botThread.CancelAsync(); userHandlers.Clear(); DisposeLog(); }
private static void OnLoggedOff(SteamUser.LoggedOffCallback callback) { Log.Info("Logged off"); isLoggedOn = false; if (quitOnDisconnect) { steamClient.Disconnect(); } }
public void Dispose() { myLogger.LogTrace("Disposing GameCoordinatorClient"); if (myCsgoClient != null) { myCsgoClient.Dispose(); mySteamClient.Disconnect(); } }
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(); }
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(); } }
internal void Stop() { if (SteamClient == null) { return; } SteamClient.Disconnect(); SteamClient = null; CallbackManager = null; }
public void MainLoop() { // 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)); } steamClient.Disconnect(); }
protected virtual void Dispose(bool disposing) { if (disposing) { if (steamClient != null) { steamClient.Disconnect(); steamClient = null; } } }
static void Main(string[] args) { if (args.Length < 4) { Console.WriteLine("usage: SteamLB.exe <username> <password> <appid> <leaderboardListFile>"); return; } Run(args); steamClient.Disconnect(); }
/// <summary> /// Disconnect from the Steam network and stop the callback /// thread. /// </summary> public void StopBot() { IsRunning = false; Log.Debug("Trying to shut down bot thread."); SteamClient.Disconnect(); botThread.CancelAsync(); while (botThread.IsBusy) { Thread.Yield(); } userHandlers.Clear(); }
internal async Task Stop() { if (!IsRunning) { return; } await CardsFarmer.StopFarming().ConfigureAwait(false); IsRunning = false; SteamClient.Disconnect(); }
public void Disconnect() { isConnected = false; isRunning = false; if (steamFriends.GetPersonaState() != EPersonaState.Offline) { steamFriends.SetPersonaState(EPersonaState.Offline); } steamUser.LogOff(); steamClient.Disconnect(); }
/// <summary> /// 停止机器人实例 /// </summary> public void Stop() { lock (_startStopLock) { if (_loginPending) { LoginSemaphore.Release(); _loginPending = false; } _mqChannel?.Close(); SteamClient.Disconnect(); _logger.Info($"#{SequenceNumber} Stopped."); } }
public void Disconnect() { stop = true; steamUser.LogOff(); steamClient.Disconnect(); CancelTradeOfferPollingThread(); botThread.CancelAsync(); while (botThread.IsBusy) { Thread.Yield(); } Console.WriteLine("stopping bot {0} ...", Name); }
private void OnDisconnected(SteamClient.DisconnectedCallback callback) { dotaIsReady = false; Console.WriteLine("Disconnected from Steam, reconnecting in 5 seconds..."); System.Threading.Thread.Sleep(5000); if (dota != null && dota.Ready) { dota.Stop(); } if (steamClient.IsConnected) { steamClient.Disconnect(); } steamClient.Connect(); }
/// <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 ECheckResult StartSteam() { _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.UpdateMachineAuthCallback>(OnMachineAuth); _isRunning = true; _steamClient.Connect(); while (_isRunning) _manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); if (_operation == EOperationType.CreateSentry) Thread.Sleep(500); _steamClient.Disconnect(); return _checkResult; }
internal async Task Init(SteamClient steamClient, string webAPIUserNonce, string vanityURL, string parentalPin) { if (steamClient == null || steamClient.SteamID == null || string.IsNullOrEmpty(webAPIUserNonce)) { return; } SteamID = steamClient.SteamID; VanityURL = vanityURL; string sessionID = Convert.ToBase64String(Encoding.UTF8.GetBytes(SteamID.ToString(CultureInfo.InvariantCulture))); // Generate an AES session key byte[] sessionKey = CryptoHelper.GenerateRandomBlock(32); // RSA encrypt it with the public key for the universe we're on byte[] cryptedSessionKey = null; using (RSACrypto rsa = new RSACrypto(KeyDictionary.GetPublicKey(steamClient.ConnectedUniverse))) { cryptedSessionKey = rsa.Encrypt(sessionKey); } // Copy our login key byte[] loginKey = new byte[20]; Array.Copy(Encoding.ASCII.GetBytes(webAPIUserNonce), loginKey, webAPIUserNonce.Length); // AES encrypt the loginkey with our session key byte[] cryptedLoginKey = CryptoHelper.SymmetricEncrypt(loginKey, sessionKey); // Send the magic KeyValue authResult; Logging.LogGenericInfo(Bot.BotName, "Logging in to ISteamUserAuth..."); using (dynamic iSteamUserAuth = WebAPI.GetInterface("ISteamUserAuth")) { iSteamUserAuth.Timeout = Timeout; try { authResult = iSteamUserAuth.AuthenticateUser( steamid: SteamID, sessionkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedSessionKey, 0, cryptedSessionKey.Length)), encrypted_loginkey: Encoding.ASCII.GetString(WebUtility.UrlEncodeToBytes(cryptedLoginKey, 0, cryptedLoginKey.Length)), method: WebRequestMethods.Http.Post, secure: true ); } catch (Exception e) { Logging.LogGenericException(Bot.BotName, e); steamClient.Disconnect(); // We may get 403 if we use the same webAPIUserNonce twice return; } } if (authResult == null) { steamClient.Disconnect(); // Try again return; } Logging.LogGenericInfo(Bot.BotName, "Success!"); string steamLogin = authResult["token"].AsString(); string steamLoginSecure = authResult["tokensecure"].AsString(); SteamCookieDictionary.Clear(); SteamCookieDictionary.Add("sessionid", sessionID); SteamCookieDictionary.Add("steamLogin", steamLogin); SteamCookieDictionary.Add("steamLoginSecure", steamLoginSecure); SteamCookieDictionary.Add("birthtime", "-473356799"); // ( ͡° ͜ʖ ͡°) if (!string.IsNullOrEmpty(parentalPin) && !parentalPin.Equals("0")) { Logging.LogGenericInfo(Bot.BotName, "Unlocking parental account..."); Dictionary<string, string> postData = new Dictionary<string, string>() { {"pin", parentalPin} }; HttpResponseMessage response = await Utilities.UrlPostRequestWithResponse("https://steamcommunity.com/parental/ajaxunlock", postData, SteamCookieDictionary, "https://steamcommunity.com/").ConfigureAwait(false); if (response != null && response.IsSuccessStatusCode) { Logging.LogGenericInfo(Bot.BotName, "Success!"); var setCookieValues = response.Headers.GetValues("Set-Cookie"); foreach (string setCookieValue in setCookieValues) { if (setCookieValue.Contains("steamparental=")) { string setCookie = setCookieValue.Substring(setCookieValue.IndexOf("steamparental=") + 14); setCookie = setCookie.Substring(0, setCookie.IndexOf(';')); SteamCookieDictionary.Add("steamparental", setCookie); break; } } } else { Logging.LogGenericInfo(Bot.BotName, "Failed!"); } } Bot.Trading.CheckTrades(); }