void HandleFromGC( IPacketMsg packetMsg )
        {
            var msg = new ClientMsgProtobuf<CMsgGCClient>( packetMsg );

            var callback = new MessageCallback( msg.Body );
            this.Client.PostCallback( callback );
        }
Beispiel #2
0
        /// <summary>
        /// Request to see if the client user has any comment notifications
        /// </summary>
        public void RequestCommentNotifications()
        {
            var clientRequestCommentNotifications =
                new ClientMsgProtobuf<CMsgClientRequestCommentNotifications>(EMsg.ClientRequestCommentNotifications);

            Client.Send(clientRequestCommentNotifications);
        }
        void HandleWebAPINonce(IPacketMsg packetMsg)
        {
            var nonceMsg = new ClientMsgProtobuf<CMsgClientRequestWebAPIAuthenticateUserNonceResponse>(packetMsg);

            var callback = new NonceCallback(nonceMsg.Body);
            Client.PostCallback(callback);
        }
        private static void HandleClientRequestFreeLicenseResponse(IPacketMsg packetMsg)
        {
            var resp = new ClientMsgProtobuf<CMsgClientRequestFreeLicenseResponse>(packetMsg);

            JobAction job;
            JobManager.TryRemoveJob(packetMsg.TargetJobID, out job);

            var packageIDs = resp.Body.granted_packageids;
            var appIDs = resp.Body.granted_appids;

            Log.WriteDebug("FreeLicense", "Received free license: {0} ({1} apps, {2} packages)", (EResult)resp.Body.eresult, appIDs.Count, packageIDs.Count);

            if (packageIDs.Count > 0)
            {
                Steam.Instance.Apps.PICSGetProductInfo(Enumerable.Empty<uint>(), packageIDs);

                if (packageIDs.Count > 5)
                {
                    IRC.Instance.SendMain("{0}{1}{2} new free licenses granted", Colors.OLIVE, packageIDs.Count, Colors.NORMAL);
                }
                else
                {
                    foreach (var package in packageIDs)
                    {
                        IRC.Instance.SendMain("New free license granted: {0}{1}{2} -{3} {4}", Colors.OLIVE, Steam.GetPackageName(package), Colors.NORMAL, Colors.DARKBLUE, SteamDB.GetPackageURL(package));
                    }
                }
            }

            if (appIDs.Count > 0)
            {
                Steam.Instance.Apps.PICSGetAccessTokens(appIDs, Enumerable.Empty<uint>());
            }
        }
Beispiel #5
0
        void HandleInitiateTradeResult(IPacketMsg packetMsg)
        {
            var msg = new ClientMsgProtobuf<CMsgTrading_InitiateTradeResult>(packetMsg);

            var callback = new TradeRequestCallback();
            callback.Response = msg.Body.response;
            callback.TradeRequestId = msg.Body.trade_request_id;
            callback.Other = msg.Body.other_steamid;

            if (callback.Response == 0)
                callback.Status = ETradeStatus.Accepted;
            else if (callback.Response == 1)
                callback.Status = ETradeStatus.Rejected;
			else if (callback.Response == 6)
				callback.Status = ETradeStatus.Unknown;
            else if (callback.Response == 7)
                callback.Status = ETradeStatus.Cancelled;
            else if (callback.Response == 8)
                callback.Status = ETradeStatus.Unknown;
            else if (callback.Response == 11)
                callback.Status = ETradeStatus.InTrade;
            else if (callback.Response == 12)
                callback.Status = ETradeStatus.Unknown2;
            else if (callback.Response == 13)
                callback.Status = ETradeStatus.TimedOut;
            else
                throw new Exception("Unknown trade status: "+callback.Status);

            this.Client.PostCallback(callback);
        }
Beispiel #6
0
        void HandleResponse(IPacketMsg packetMsg)
        {
            var response = new ClientMsgProtobuf<CMsgClientPlayerNicknameList>(packetMsg);

            var nicknames = response.Body.nicknames;
            Client.PostCallback(new ClientPlayerNicknameListCallback(nicknames));
        }
Beispiel #7
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.Username ) || string.IsNullOrEmpty( details.Password ) )
            {
                throw new ArgumentException( "LogOn requires a username and password to be set in 'details'." );
            }

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

            SteamID gsId = new SteamID( 0, 0, Client.ConnectedUniverse, 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 = Utils.GenerateMachineID();

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

            this.Client.Send( logon );
        }
Beispiel #8
0
        /// <summary>
        /// Accepts the new Login Key provided by a <see cref="LoginKeyCallback"/>.
        /// </summary>
        /// <param name="callback">The callback containing the new Login Key.</param>
        public void AcceptNewLoginKey( LoginKeyCallback callback )
        {
            var acceptance = new ClientMsgProtobuf<CMsgClientNewLoginKeyAccepted>( EMsg.ClientNewLoginKeyAccepted );
            acceptance.Body.unique_id = callback.UniqueID;

            this.Client.Send( acceptance );
        }
Beispiel #9
0
        private void HandleClientCommentNotifications(IPacketMsg packetMsg)
        {
            var clientCommentNotifications = new ClientMsgProtobuf<CMsgClientCommentNotifications>(packetMsg);

            CMsgClientCommentNotifications result = clientCommentNotifications.Body;

            Client.PostCallback(new CommentNotificationCallback(result));
        }
        void HandleSteamLevelsResponse( IPacketMsg msg )
        {
            var clientMsg = new ClientMsgProtobuf<CMsgClientFSGetFriendsSteamLevelsResponse>( msg );

            var callback = new SteamLevelsCallback( clientMsg.TargetJobID, clientMsg.Body );

            Client.PostCallback( callback );
        }
Beispiel #11
0
        /// <summary>
        /// Cancels a pending trade request.
        /// </summary>
        /// <param name="target">The target account you want to trade with.</param>
        public void CancelPendingTrade(SteamID target)
        {
            var cancelTrade = new ClientMsgProtobuf<CMsgTrading_CancelTradeRequest>( EMsg.EconTrading_CancelTradeRequest );

            cancelTrade.Body.other_steamid = target;

            this.Client.Send(cancelTrade);
        }
Beispiel #12
0
        private void HandleClientUserNotifications(IPacketMsg packetMsg)
        {
            var clientUserNotificationResponse = new ClientMsgProtobuf<CMsgClientUserNotifications>(packetMsg);

            CMsgClientUserNotifications result = clientUserNotificationResponse.Body;

            Client.PostCallback(new NotificationCallback(result));
        }
Beispiel #13
0
        void HandleUGCDetailsResponse( IPacketMsg packetMsg )
        {
            var infoResponse = new ClientMsgProtobuf<CMsgClientUFSGetUGCDetailsResponse>( packetMsg );

            var innerCallback = new UGCDetailsCallback( infoResponse.Body );
            var callback = new SteamClient.JobCallback<UGCDetailsCallback>( infoResponse.TargetJobID, innerCallback );
            this.Client.PostCallback( callback );
        }
        /// <summary>
        /// Sends a friend request to a user.
        /// </summary>
        /// <param name="steamId">The SteamID of the friend to add.</param>
        public void AddFriend( SteamID steamId )
        {
            var addFriend = new ClientMsgProtobuf<CMsgClientAddFriend>( EMsg.ClientAddFriend );

            addFriend.Body.steamid_to_add = steamId;

            this.Client.Send( addFriend );
        }
Beispiel #15
0
        /// <summary>
        /// Proposes a trade to another client.
        /// </summary>
        /// <param name="user">The client to trade.</param>
        public void Trade( SteamID user )
        {
            var tradeReq = new ClientMsgProtobuf<CMsgTrading_InitiateTradeRequest>( EMsg.EconTrading_InitiateTradeRequest );

            tradeReq.Body.other_steamid = user;

            Client.Send( tradeReq );
        }
        /// <summary>
        /// Sends a friend request to a user.
        /// </summary>
        /// <param name="accountNameOrEmail">The account name or email of the user.</param>
        public void AddFriend( string accountNameOrEmail )
        {
            var addFriend = new ClientMsgProtobuf<CMsgClientAddFriend>( EMsg.ClientAddFriend );

            addFriend.Body.accountname_or_email_to_add = accountNameOrEmail;

            this.Client.Send( addFriend );
        }
Beispiel #17
0
        /// <summary>
        /// Cancels an already sent trade proposal.
        /// </summary>
        /// <param name="user">The user.</param>
        public void CancelTrade( SteamID user )
        {
            var cancelTrade = new ClientMsgProtobuf<CMsgTrading_CancelTradeRequest>( EMsg.EconTrading_CancelTradeRequest );

            cancelTrade.Body.other_steamid = user;

            Client.Send( cancelTrade );
        }
        void HandleAccountDataResponse( IPacketMsg packetMsg )
        {
            var msg = new ClientMsgProtobuf<CMsgClientRequestAccountDataResponse>( packetMsg );

            var callback = new ResponseCallback( msg.TargetJobID, msg.Body );

            Client.PostCallback( callback );
        }
Beispiel #19
0
        /// <summary>
        /// Responds to a trade proposal.
        /// </summary>
        /// <param name="tradeId">The trade id of the received proposal.</param>
        /// <param name="acceptTrade">if set to <c>true</c>, the trade will be accepted.</param>
        public void RespondToTrade( uint tradeId, bool acceptTrade )
        {
            var tradeResp = new ClientMsgProtobuf<CMsgTrading_InitiateTradeResponse>( EMsg.EconTrading_InitiateTradeResponse );

            tradeResp.Body.trade_request_id = tradeId;
            tradeResp.Body.response = acceptTrade ? 0u : 1u;

            Client.Send( tradeResp );
        }
Beispiel #20
0
 public static void LaunchGame(ulong appid)
 {
     var clientMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>(EMsg.ClientGamesPlayedNoDataBlob);
     clientMsg.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
     {
         game_id = appid,
     });
     steamClient.Send(clientMsg);
 }
        /// <summary>
        /// Handles a client message. This should not be called directly.
        /// </summary>
        /// <param name="packetMsg">The packet message that contains the data.</param>
        public override void HandleMsg( IPacketMsg packetMsg )
        {
            if ( packetMsg.MsgType == EMsg.ClientFromGC )
            {
                var msg = new ClientMsgProtobuf<CMsgGCClient>( packetMsg );

                var callback = new MessageCallback( msg.Body );
                this.Client.PostCallback( callback );
            }
        }
Beispiel #22
0
        /// <summary>
        /// Responds to a trade request from another Steam account.
        /// If the trade is accepted, a <see cref="SteamTrading.StartSessionCallback"/> will be received.
        /// </summary>
        /// <param name="target">The target account you want to trade with.</param>
        public void RespondTradeRequest(UInt32 tradeRequestId, SteamID otherId, bool accept)
        {
            var responseTrade = new ClientMsgProtobuf<CMsgTrading_InitiateTradeResponse>(EMsg.EconTrading_InitiateTradeRequest);

            responseTrade.Body.trade_request_id = tradeRequestId;
            responseTrade.Body.other_steamid = otherId;
            responseTrade.Body.response = accept ? 0u : 1u;

            this.Client.Send(responseTrade);
        }
Beispiel #23
0
        /// <summary>
        /// Requests a trade with another Steam account.
        /// Results are returned in <see cref="SteamTrading.TradeRequestCallback"/>.
        /// </summary>
        /// <param name="target">The target account you want to trade with.</param>
        public void RequestTrade(SteamID target)
        {
            var requestTrade = new ClientMsgProtobuf<CMsgTrading_InitiateTradeRequest>( EMsg.EconTrading_InitiateTradeRequest );

            requestTrade.Body.trade_request_id = 0;
            requestTrade.Body.other_steamid = target;
            requestTrade.Body.other_name = null;

            this.Client.Send(requestTrade);
        }
Beispiel #24
0
        /// <summary>
        /// Sets the local user's persona state and broadcasts it over the network.
        /// </summary>
        /// <param name="state">The state.</param>
        public void SetPersonaState( EPersonaState state )
        {
            cache.LocalUser.PersonaState = state;

            var stateMsg = new ClientMsgProtobuf<CMsgClientChangeStatus>( EMsg.ClientChangeStatus );
            stateMsg.Body.persona_state = ( uint )state;
            stateMsg.Body.player_name = cache.LocalUser.Name;

            this.Client.Send( stateMsg );
        }
        /// <summary>
        /// Requests an app ownership ticket for the specified AppID.
        /// Results are returned in a <see cref="AppOwnershipTicketCallback"/> callback.
        /// </summary>
        /// <param name="appid">The appid to request the ownership ticket of.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="SteamClient.JobCallback&lt;T&gt;"/>.</returns>
        public JobID GetAppOwnershipTicket( uint appid )
        {
            var request = new ClientMsgProtobuf<CMsgClientGetAppOwnershipTicket>( EMsg.ClientGetAppOwnershipTicket );
            request.SourceJobID = Client.GetNextJobID();

            request.Body.app_id = appid;

            this.Client.Send( request );

            return request.SourceJobID;
        }
        public void Send( byte[] data, uint appId )
        {
            var clientMsg = new ClientMsgProtobuf<CMsgGCClient>( EMsg.ClientToGC );

            clientMsg.Body.msgtype = BitConverter.ToUInt32( data, 0 );
            clientMsg.Body.appid = appId;

            clientMsg.Body.payload = data;

            this.Client.Send( clientMsg );
        }
Beispiel #27
0
        /// <summary>
        /// Sets the local user's persona name and broadcasts it over the network.
        /// </summary>
        /// <param name="name">The name.</param>
        public void SetPersonaName( string name )
        {
            // cache the local name right away, so that early calls to SetPersonaState don't reset the set name
            cache.LocalUser.Name = name;

            var stateMsg = new ClientMsgProtobuf<CMsgClientChangeStatus>( EMsg.ClientChangeStatus );
            stateMsg.Body.persona_state = ( uint )cache.LocalUser.PersonaState;
            stateMsg.Body.player_name = name;

            this.Client.Send( stateMsg );
        }
        public JobID RequestLevels( IEnumerable<SteamID> steamIds )
        {
            var clientMsg = new ClientMsgProtobuf<CMsgClientFSGetFriendsSteamLevels>( EMsg.ClientFSGetFriendsSteamLevels );
            clientMsg.SourceJobID = Client.GetNextJobID();

            clientMsg.Body.accountids.AddRange( steamIds.Select( s => s.AccountID ) );

            Client.Send( clientMsg );

            return clientMsg.SourceJobID;
        }
        public void PlayGame( GameID game )
        {
            var clientMsg = new ClientMsgProtobuf<CMsgClientGamesPlayed>( EMsg.ClientGamesPlayedNoDataBlob );

            clientMsg.Body.games_played.Add( new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = game,
            } );

            Client.Send( clientMsg );
        }
        /// <summary>
        /// Requests details for a specific item of user generated content from the Steam servers.
        /// Results are returned in a <see cref="UGCDetailsCallback"/> from a <see cref="SteamClient.JobCallback&lt;T&gt;"/>.
        /// </summary>
        /// <param name="ugcId">The unique user generated content id.</param>
        /// <returns>The Job ID of the request. This can be used to find the appropriate <see cref="SteamClient.JobCallback&lt;T&gt;"/>.</returns>
        public JobID RequestUGCDetails( UGCHandle ugcId )
        {
            var request = new ClientMsgProtobuf<CMsgClientUFSGetUGCDetails>( EMsg.ClientUFSGetUGCDetails );
            request.SourceJobID = Client.GetNextJobID();

            request.Body.hcontent = ugcId;

            this.Client.Send( request );

            return request.SourceJobID;
        }
Beispiel #31
0
        internal string itemDropDefList(Bot bot)
        {
            ClientMsgProtobuf <CMsgClientGamesPlayed> response = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            string IDDL_File        = @"plugins\\ASFItemDropper\\idropdeflist.txt";
            string idropdeflist_txt = "";

            bool fileExists = File.Exists(IDDL_File);

            if (fileExists)
            {
                idropdeflist_txt  = "\n";
                idropdeflist_txt += System.IO.File.ReadAllText(IDDL_File);
            }
            else
            {
                idropdeflist_txt = "## INFO: File 'idropdeflist.txt' does not exist.";
            }

            return(idropdeflist_txt);
        }
Beispiel #32
0
        public async Task <PurchaseResponseCallback> RedeemKey(string _keyToActivate)
        {
            ClientMsgProtobuf <CMsgClientRegisterKey> registerKey = new ClientMsgProtobuf <CMsgClientRegisterKey>(EMsg.ClientRegisterKey)
            {
                SourceJobID = Client.GetNextJobID()
            };

            registerKey.Body.key = _keyToActivate;

            Client.Send(registerKey);

            try
            {
                return(await new AsyncJob <PurchaseResponseCallback>(Client, registerKey.SourceJobID));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
Beispiel #33
0
        public static void PlayGames(List <uint> gameIDs, string NonSteam)
        {
            ClientMsgProtobuf <CMsgClientGamesPlayed> request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            if (NonSteam.ToString() != "disable")
            {
                request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id         = 12350489788975939584,
                    game_extra_info = NonSteam
                });
            }

            foreach (uint gameID in gameIDs.Where(gameID => gameID != 0))
            {
                request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_id = new GameID(gameID)
                });
            }
            AccountLogin.steamClient.Send(request);
        }
Beispiel #34
0
        internal void SetCurrentMode(uint chatMode)
        {
            if (chatMode == 0)
            {
                ArchiLogger.LogNullError(nameof(chatMode));

                return;
            }

            if (!Client.IsConnected)
            {
                return;
            }

            ClientMsgProtobuf <CMsgClientUIMode> request = new ClientMsgProtobuf <CMsgClientUIMode>(EMsg.ClientCurrentUIMode)
            {
                Body = { chat_mode = chatMode }
            };

            Client.Send(request);
        }
Beispiel #35
0
        public void OnMessage(IPacketMsg packetMsg)
        {
            if (packetMsg.MsgType == EMsg.ClientGetAppOwnershipTicketResponse)
            {
                var pb = new ClientMsgProtobuf <CMsgClientGetAppOwnershipTicketResponse>(packetMsg);
                log.Debug("Got client ticket of " + pb.Body.app_id + " " + pb.Body.eresult + " " + pb.Body.ticket.Length);

                if (pb.Body.eresult == (uint)EResult.OK)
                {
                    AppOwnershipTicket = pb.Body.ticket;
                }
            }
            else if (packetMsg.MsgType == EMsg.ClientAuthListAck)
            {
                var pb = new ClientMsgProtobuf <CMsgClientAuthListAck>(packetMsg);
                log.Debug("Steam acked ticket crc of "
                          + pb.Body.ticket_crc
                          + "/"
                          + pb.Body.message_sequence);
                TicketForAuth   = PendingTicketForAuth;
                TicketForServer = AuthTicket.CreateServerTicket();
            }
            else if (packetMsg.MsgType == EMsg.ClientTicketAuthComplete)
            {
                var pb = new ClientMsgProtobuf <CMsgClientTicketAuthComplete>(packetMsg);
                log.Debug("Client ticket auth complete with "
                          + pb.Body.estate
                          + " on "
                          + pb.Body.ticket_crc);
            }
            else if (packetMsg.MsgType == EMsg.ClientOGSBeginSessionResponse)
            {
                var msg = new ClientMsg <MsgClientOGSBeginSessionResponse>(packetMsg);

                if (msg.Body.Result == EResult.OK)
                {
                    SteamworksSessionId = msg.Body.SessionId;
                }
            }
        }
Beispiel #36
0
        // called when the client successfully (or unsuccessfully) logs onto an account
        void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                // logon failed (password incorrect, steamguard enabled, etc)
                // an EResult of AccountLogonDenied means the account has SteamGuard enabled and an email containing the authcode was sent
                // in that case, you would get the auth code from the email and provide it in the LogOnDetails

                Console.WriteLine("Unable to logon to Steam: {0}", callback.Result);

                gotMatch = true; // we didn't actually get the match details, but we need to jump out of the callback loop
                return;
            }

            Console.WriteLine("Logged in! Launching DOTA...");

            // we've logged into the account
            // now we need to inform the steam server that we're playing dota (in order to receive GC messages)

            // steamkit doesn't expose the "play game" message through any handler, so we'll just send the message manually
            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(APPID),   // or game_id = APPID,
            });

            // send it off
            // notice here we're sending this message directly using the SteamClient
            client.Send(playGame);

            // delay a little to give steam some time to establish a GC connection to us
            Thread.Sleep(5000);

            // inform the dota GC that we want a session
            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>(( uint )EGCBaseClientMsg.k_EMsgGCClientHello);

            clientHello.Body.engine = ESourceEngine.k_ESE_Source2;
            gameCoordinator.Send(clientHello, APPID);
        }
Beispiel #37
0
        void HandleLoggedOff(IPacketMsg packetMsg)
        {
            SessionID = null;
            SteamID   = null;

            CellID        = null;
            PublicIP      = null;
            IPCountryCode = null;

            heartBeatFunc.Stop();

            if (packetMsg.IsProto)
            {
                var logoffMsg    = new ClientMsgProtobuf <CMsgClientLoggedOff>(packetMsg);
                var logoffResult = (EResult)logoffMsg.Body.eresult;

                if (logoffResult == EResult.TryAnotherCM || logoffResult == EResult.ServiceUnavailable)
                {
                    Servers.TryMark(connection.CurrentEndPoint, connection.ProtocolTypes, ServerQuality.Bad);
                }
            }
        }
Beispiel #38
0
        internal async Task <PurchaseResponseCallback> RedeemKey(string key)
        {
            if (string.IsNullOrEmpty(key) || !Client.IsConnected)
            {
                return(null);
            }

            var request = new ClientMsgProtobuf <CMsgClientRegisterKey>(EMsg.ClientRegisterKey)
            {
                SourceJobID = Client.GetNextJobID()
            };

            request.Body.key = key;

            Client.Send(request);
            try {
                return(await new AsyncJob <PurchaseResponseCallback>(Client, request.SourceJobID));
            } catch (Exception e) {
                Logging.LogGenericException(e);
                return(null);
            }
        }
        /*
         * __  __        _    _                 _
         |  \/  |  ___ | |_ | |__    ___    __| | ___
         | |\/| | / _ \| __|| '_ \  / _ \  / _` |/ __|
         | |  | ||  __/| |_ | | | || (_) || (_| |\__ \
         |_|  |_| \___| \__||_| |_| \___/  \__,_||___/
         |
         */

        internal void PlayGame(string gameName)
        {
            if (!Client.IsConnected)
            {
                return;
            }

            ClientMsgProtobuf <CMsgClientGamesPlayed> request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            if (!string.IsNullOrEmpty(gameName))
            {
                request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_extra_info = gameName,
                    game_id         = new GameID {
                        AppType = GameID.GameType.Shortcut,
                        ModID   = uint.MaxValue
                    }
                });
            }

            Client.Send(request);
        }
Beispiel #40
0
        private void ClientGamesPlayedWithDataBlob(uint gameFlags)
        {
            var changeDataBlobRequest = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayedWithDataBlob);

            changeDataBlobRequest.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                steam_id_gs           = 0,
                game_id               = new GameID(CSGOClient.CSGO_APPID),
                game_ip_address       = 0,
                game_port             = 0,
                is_secure             = true,
                game_extra_info       = "",
                game_data_blob        = Utils.StringToByteArray("test"),
                process_id            = 5364,
                streaming_provider_id = 0,
                game_flags            = gameFlags,
                owner_id              = Convert.ToUInt32(CSGOClient.steamId - 76561197960265728),
                launch_option_type    = 0,
                launch_source         = 0
            });
            changeDataBlobRequest.Body.client_os_type = 16;
        }
Beispiel #41
0
        public void Auth()
        {
            var pb = new CMsgAuthTicket();

            pb.gameid       = App;
            pb.h_steam_pipe = 327684;

            using (var stream = Bitstream.CreateWith(PendingTicketForAuth.ToArray())) {
                pb.ticket_crc = CrcUtils.Compute32(stream);
            }

            pb.ticket = PendingTicketForAuth.ToArray();

            var msg = new ClientMsgProtobuf <CMsgClientAuthList>(EMsg.ClientAuthList);

            msg.Body.tokens_left = Bot.TokenCount;
            msg.Body.app_ids.Add(App);
            msg.Body.tickets.Add(pb);
            msg.Body.message_sequence = AuthSequence++;
            Bot.Client.Send(msg);
            log.Debug("Sent auth list with crc " + msg.Body.tickets[0].ticket_crc + "/" + msg.Body.message_sequence);
        }
Beispiel #42
0
        public void SetPlayingGame(string botId, uint[] appIds, string gameName)
        {
            var playGameMessage = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            if (!string.IsNullOrWhiteSpace(gameName))
            {
                playGameMessage.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_extra_info = gameName,
                    game_id         = new GameID
                    {
                        AppType = GameID.GameType.Shortcut,
                        ModID   = uint.MaxValue
                    }
                });
            }
            foreach (var appId in appIds)
            {
                playGameMessage.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
                {
                    game_id = new GameID(appId)
                });
            }
            if (botId == null)
            {
                if (SteamBot.BotInstances == null)
                {
                    return;
                }
                foreach (var bot in SteamBot.BotInstances)
                {
                    bot.SteamClient.Send(playGameMessage);
                }
                return;
            }
            var botInstance = SteamBot.BotInstances?.SingleOrDefault(b => b.Id == botId);

            botInstance?.SteamClient.Send(playGameMessage);
        }
        private void HandleStoreUserStatsResponse(IPacketMsg packetMsg)
        {
            if (packetMsg == null)
            {
                ASF.ArchiLogger.LogNullError(nameof(packetMsg));
                return;
            }
            ClientMsgProtobuf <CMsgClientStoreUserStatsResponse> response = new ClientMsgProtobuf <CMsgClientStoreUserStatsResponse>(packetMsg);

            if (!Responses.TryAdd(response.Body.game_id, new StoredResponse {
                Success = response.Body.eresult == 1,
                Response = null                 //we don't care about this, just need to know that request was successful
            }))
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorFailingRequest, "SetAchievements"));
            }

            if (response.Body.eresult != 1)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorFailingRequest, "SetAchievements"));
            }
        }
        private void HandleGetUserStatsResponse(IPacketMsg packetMsg)
        {
            if (packetMsg == null)
            {
                ASF.ArchiLogger.LogNullError(nameof(packetMsg));
                return;
            }
            ClientMsgProtobuf <CMsgClientGetUserStatsResponse> response = new ClientMsgProtobuf <CMsgClientGetUserStatsResponse>(packetMsg);

            if (!Responses.TryAdd(response.Body.game_id, new StoredResponse {
                Success = response.Body.eresult == 1,
                Response = response.Body
            }))
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorFailingRequest, "GetAchievements"));
            }

            if (response.Body.eresult != 1)
            {
                ASF.ArchiLogger.LogGenericError(string.Format(Strings.ErrorFailingRequest, "GetAchievements"));
            }
        }
Beispiel #45
0
        public static void LaunchClient()
        {
            new Callback <SteamGameCoordinator.MessageCallback>(OnGCMessage, SteamApp.manager);

            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed
            {
                game_id = new GameID(730), // or game_id = APPID,
            });

            // send it off
            // notice here we're sending this message directly using the SteamClient
            SteamApp.steamClient.Send(playGame);
            Thread.Sleep(3000);
            clientLaunched = true;
            CSGOClientLaunchedCallback.SafeInvoke();

            var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            SteamApp.steamGameCoordinator.Send(clientHello, 730);
        }
        /*
         * __  __        _    _                 _
         |  \/  |  ___ | |_ | |__    ___    __| | ___
         | |\/| | / _ \| __|| '_ \  / _ \  / _` |/ __|
         | |  | ||  __/| |_ | | | || (_) || (_| |\__ \
         |_|  |_| \___| \__||_| |_| \___/  \__,_||___/
         |
         */

        // TODO: Remove me once https://github.com/SteamRE/SteamKit/issues/305 is fixed
        internal void LogOnWithoutMachineID(SteamUser.LogOnDetails details)
        {
            ClientMsgProtobuf <CMsgClientLogon> logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon);

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

            if (details.LoginID != null)
            {
                logon.Body.obfustucated_private_ip = details.LoginID.Value;
            }

            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;

            logon.Body.client_package_version = 1771;

            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);


            Client.Send(logon);
        }
Beispiel #47
0
        static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            // Check to see if we've logged on successfully.
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    // Account has Steam Guard enabled.
                    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!");

            // Start playing a game.
            var playGame = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            // Convert application IDs to array.
            int[] GameAppIDs = AppIDs.ToArray();

            // Loop application IDs to add.
            foreach (int AppID in GameAppIDs)
            {
                Console.WriteLine(":: Now playing game '{0}'!", AppID.ToString());
                playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_id = new GameID(AppID)
                });
            }

            steamClient.Send(playGame);
        }
Beispiel #48
0
        public void JoinLobby(ulong _lobbyId, string _username)
        {
            if (inLobby())
            {
                LeaveLobby();
            }

            lobbyId = _lobbyId;

            StopMatchmaking();
            Testt();

            var joinRequest = new ClientMsgProtobuf <CMsgClientMMSJoinLobby>(EMsg.ClientMMSJoinLobby);

            joinRequest.ProtoHeader.routing_appid  = CSGO_APPID;
            joinRequest.Header.Proto.routing_appid = CSGO_APPID;
            joinRequest.Body.app_id         = CSGO_APPID;
            joinRequest.Body.steam_id_lobby = _lobbyId;
            joinRequest.Body.persona_name   = _username;
            steamClient.Send(joinRequest);

            form.AddLog(string.Format("Joining lobbyId : {0} with username : {1}", _lobbyId, _username));
        }
Beispiel #49
0
        private static void OnAccountInfo(SteamUser.AccountInfoCallback callback)
        {
            Country = callback.Country;

            var stateMsg = new ClientMsgProtobuf <CMsgClientChangeStatus>(EMsg.ClientChangeStatus)
            {
                Body =
                {
                    persona_state       = (uint)EPersonaState.Online,
                    persona_state_flags = uint.MaxValue,
                    player_name         = Steam.Instance.Friends.GetPersonaName()
                }
            };

            Steam.Instance.Client.Send(stateMsg);

            if (Settings.IsFullRun)
            {
                InGameShorcut.game_extra_info = $"\u23E9 Full run: {Settings.Current.FullRun.ToString()}";
            }

            Sync();
        }
Beispiel #50
0
        internal void PlayGames(ICollection <uint> gameIDs)
        {
            if (gameIDs == null || gameIDs.Count == 0 || !Client.IsConnected)
            {
                return;
            }

            var request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            foreach (uint gameID in gameIDs)
            {
                if (gameID == 0)
                {
                    continue;
                }

                request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_id = new GameID(gameID),
                });
            }

            Client.Send(request);
        }
Beispiel #51
0
        internal void PlayGames(params uint[] gameIDs)
        {
            if (!Client.IsConnected)
            {
                return;
            }

            var request = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            foreach (uint gameID in gameIDs)
            {
                if (gameID == 0)
                {
                    continue;
                }

                request.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                    game_id = new GameID(gameID),
                });
            }

            Client.Send(request);
        }
Beispiel #52
0
        void HandleChangesResponse(IPacketMsg packetMsg)
        {
            var changesResponse = new ClientMsgProtobuf <CMsgClientPICSChangesSinceResponse>(packetMsg);

            if (lastChangelist == changesResponse.Body.current_change_number)
            {
                return;
            }

            lastChangelist = changesResponse.Body.current_change_number;

            if (changesResponse.Body.app_changes.Count > 0 || changesResponse.Body.package_changes.Count > 0)
            {
                // this is dirty
                // but because we live in a multiverse that consists of infinite universes
                // i justify this because this method is totally acceptable in at least one of those universes
                Client.GetHandler <SteamApps>().PICSGetProductInfo(
                    apps: changesResponse.Body.app_changes.Select(a => a.appid),
                    packages: changesResponse.Body.package_changes.Select(p => p.packageid),
                    onlyPublic: false
                    );
            }
        }
Beispiel #53
0
        void HandleMulti(IPacketMsg packetMsg)
        {
            if (!packetMsg.IsProto)
            {
                DebugLog.WriteLine("CMClient", "HandleMulti got non-proto MsgMulti!!");
                return;
            }

            var msgMulti = new ClientMsgProtobuf <CMsgMulti>(packetMsg);

            byte[] payload = msgMulti.Body.message_body;

            if (msgMulti.Body.size_unzipped > 0)
            {
                try
                {
                    payload = ZipUtil.Decompress(payload);
                }
                catch (Exception ex)
                {
                    DebugLog.WriteLine("CMClient", "HandleMulti encountered an exception when decompressing.\n{0}", ex.ToString());
                    return;
                }
            }

            using (var ms = new MemoryStream(payload))
                using (var br = new BinaryReader(ms))
                {
                    while ((ms.Length - ms.Position) != 0)
                    {
                        int    subSize = br.ReadInt32();
                        byte[] subData = br.ReadBytes(subSize);

                        OnClientMsgReceived(GetPacketMsg(subData));
                    }
                }
        }
Beispiel #54
0
        void HandleLogOnResponse(IPacketMsg packetMsg)
        {
            if (!packetMsg.IsProto)
            {
                // a non proto ClientLogonResponse can come in as a result of connecting but never sending a ClientLogon
                // in this case, it always fails, so we don't need to do anything special here
                LogDebug("CMClient", "Got non-proto logon response, this is indicative of no logon attempt after connecting.");
                return;
            }

            var logonResp   = new ClientMsgProtobuf <CMsgClientLogonResponse>(packetMsg);
            var logonResult = ( EResult )logonResp.Body.eresult;

            if (logonResult == EResult.OK)
            {
                SessionID = logonResp.ProtoHeader.client_sessionid;
                SteamID   = logonResp.ProtoHeader.steamid;

                CellID        = logonResp.Body.cell_id;
                PublicIP      = logonResp.Body.public_ip.GetIPAddress();
                IPCountryCode = logonResp.Body.ip_country_code;

                int hbDelay = logonResp.Body.out_of_game_heartbeat_seconds;

                // restart heartbeat
                heartBeatFunc.Stop();
                heartBeatFunc.Delay = TimeSpan.FromSeconds(hbDelay);
                heartBeatFunc.Start();
            }
            else if (logonResult == EResult.TryAnotherCM || logonResult == EResult.ServiceUnavailable)
            {
                if (connection?.CurrentEndPoint != null)
                {
                    Servers.TryMark(connection.CurrentEndPoint, connection.ProtocolTypes, ServerQuality.Bad);
                }
            }
        }
Beispiel #55
0
        internal async Task <PurchaseResponseCallback> RedeemKey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                ArchiLogger.LogNullError(nameof(key));

                return(null);
            }

            if (Client == null)
            {
                ArchiLogger.LogNullError(nameof(Client));

                return(null);
            }

            if (!Client.IsConnected)
            {
                return(null);
            }

            ClientMsgProtobuf <CMsgClientRegisterKey> request = new ClientMsgProtobuf <CMsgClientRegisterKey>(EMsg.ClientRegisterKey)
            {
                SourceJobID = Client.GetNextJobID(),
                Body        = { key = key }
            };

            Client.Send(request);

            try {
                return(await new AsyncJob <PurchaseResponseCallback>(Client, request.SourceJobID).ToLongRunningTask().ConfigureAwait(false));
            } catch (Exception e) {
                ArchiLogger.LogGenericException(e);

                return(null);
            }
        }
Beispiel #56
0
        internal async Task <RedeemGuestPassResponseCallback> RedeemGuestPass(ulong guestPassID)
        {
            if (guestPassID == 0)
            {
                ArchiLogger.LogNullError(nameof(guestPassID));

                return(null);
            }

            if (Client == null)
            {
                ArchiLogger.LogNullError(nameof(Client));

                return(null);
            }

            if (!Client.IsConnected)
            {
                return(null);
            }

            ClientMsgProtobuf <CMsgClientRedeemGuestPass> request = new ClientMsgProtobuf <CMsgClientRedeemGuestPass>(EMsg.ClientRedeemGuestPass)
            {
                SourceJobID = Client.GetNextJobID(),
                Body        = { guest_pass_id = guestPassID }
            };

            Client.Send(request);

            try {
                return(await new AsyncJob <RedeemGuestPassResponseCallback>(Client, request.SourceJobID).ToLongRunningTask().ConfigureAwait(false));
            } catch (Exception e) {
                ArchiLogger.LogGenericException(e);

                return(null);
            }
        }
Beispiel #57
0
        void HandleLoggedOff(IPacketMsg packetMsg)
        {
            SessionID = null;
            SteamID   = null;

            CellID        = null;
            PublicIP      = null;
            IPCountryCode = null;

            heartBeatFunc.Stop();

            if (packetMsg.IsProto)
            {
                var logoffMsg    = new ClientMsgProtobuf <CMsgClientLoggedOff>(packetMsg);
                var logoffResult = ( EResult )logoffMsg.Body.eresult;

                if (logoffResult == EResult.TryAnotherCM || logoffResult == EResult.ServiceUnavailable)
                {
                    DebugLog.Assert(connection != null, nameof(CMClient), "No connection object during ClientLoggedOff.");
                    DebugLog.Assert(connection.CurrentEndPoint != null, nameof(CMClient), "No connection endpoint during ClientLoggedOff - cannot update server list status");
                    Servers.TryMark(connection.CurrentEndPoint, connection.ProtocolTypes, ServerQuality.Bad);
                }
            }
        }
Beispiel #58
0
        private void OnLoggedOn(SteamUser.LoggedOnCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                if (callback.Result == EResult.AccountLogonDenied)
                {
                    Console.WriteLine($"{username}: Unable to logon to Steam: This account is SteamGuard protected");

                    isRunning = false;
                    return;
                }

                Console.WriteLine($"{username}: Unable to logon to Steam: {callback.Result} / {callback.ExtendedResult}");

                isRunning = false;
                return;
            }

            Console.WriteLine("Successfully logged on!");
            steamid = callback.ClientSteamID.ConvertToUInt64();

            var Play = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed);

            Play.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed {
                game_id = new GameID(730),
            });
            steamClient.Send(Play);

            Thread.Sleep(SLEEP);

            var ClientHello = new ClientGCMsgProtobuf <CMsgClientHello>((uint)EGCBaseClientMsg.k_EMsgGCClientHello);

            SteamGameCoordinator.Send(ClientHello, 730);

            sw.Start();
        }
Beispiel #59
0
        private AsyncJob <SteamTicketAccepted> VerifyTicket(uint appId, MemoryStream stream, out uint crc)
        {
            var authTicket = stream.ToArray();

            crc = BitConverter.ToUInt32(CryptoHelper.CRCHash(authTicket));
            var items = _gameTickets.GetOrAdd(appId, new List <CMsgAuthTicket>());

            items.Add(new CMsgAuthTicket()
            {
                gameid     = appId,
                ticket     = authTicket,
                ticket_crc = crc
            });

            var authList = new ClientMsgProtobuf <CMsgClientAuthList>(EMsg.ClientAuthList);

            authList.Body.tokens_left = (uint)_gcTokens.Count;
            authList.Body.app_ids.AddRange(_gameTickets.Keys);
            authList.Body.tickets.AddRange(_gameTickets.Values.SelectMany(x => x));
            authList.SourceJobID = Client.GetNextJobID();
            Client.Send(authList);

            return(new AsyncJob <SteamTicketAccepted>(Client, authList.SourceJobID));
        }
Beispiel #60
0
        void HandleLogOnResponse(IPacketMsg packetMsg)
        {
            if (!packetMsg.IsProto)
            {
                DebugLog.WriteLine("CMClient", "HandleLogOnResponse got non-proto MsgClientLogonResponse!!");
                return;
            }


            var logonResp = new ClientMsgProtobuf <CMsgClientLogonResponse>(packetMsg);

            if (logonResp.Body.eresult == ( int )EResult.OK)
            {
                SessionID = logonResp.ProtoHeader.client_sessionid;
                SteamID   = logonResp.ProtoHeader.steamid;

                int hbDelay = logonResp.Body.out_of_game_heartbeat_seconds;

                // restart heartbeat
                heartBeatFunc.Stop();
                heartBeatFunc.Delay = TimeSpan.FromSeconds(hbDelay);
                heartBeatFunc.Start();
            }
        }