当前位置: 首页>>代码示例>>C#>>正文


C# SteamClient类代码示例

本文整理汇总了C#中SteamClient的典型用法代码示例。如果您正苦于以下问题:C# SteamClient类的具体用法?C# SteamClient怎么用?C# SteamClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SteamClient类属于命名空间,在下文中一共展示了SteamClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GET_GetOwnedGames_ByClass

        public void GET_GetOwnedGames_ByClass()
        {
            SteamClient client = new SteamClient();
            client.Authenticator = SteamSharp.Authenticators.APIKeyAuthenticator.ForProtectedResource( AccessConstants.APIKey );

            var response = PlayerService.GetOwnedGames( client, "76561197960434622", true, true );

            Assert.IsNotNull( response );
            Assert.IsInstanceOfType( response, typeof(PlayerService.OwnedGames) );

            Assert.IsNotNull( response.GameCount );
            Assert.IsTrue( ( response.GameCount > 5 ) );

            Assert.IsNotNull( response.Games );
            Assert.IsTrue( ( response.Games.Count > 0 ) );

            Assert.IsNotNull( response.Games[1] );

            Assert.IsNotNull( response.Games[1].GameID );
            Assert.IsNotNull( response.Games[1].HasCommunityVisibileStats );
            Assert.IsNotNull( response.Games[1].ImgIconURL );
            Assert.IsNotNull( response.Games[1].ImgLogoURL );
            Assert.IsNotNull( response.Games[1].Name );
            Assert.IsNotNull( response.Games[1].PlaytimeForever );
            Assert.IsNotNull( response.Games[1].PlaytimeTwoWeeks );
        }
开发者ID:chaoscode,项目名称:SteamSharp,代码行数:26,代码来源:IPlayerService.cs

示例2: HandlePacket

        public override void HandlePacket(ref NetworkPacket Packet, ref SteamClient Client)
        {
            redBuffer Buffer = new redBuffer();

            // We send the length first.
            Client.UpdateFriendslist();
            Buffer.WriteUInt32((UInt32)Client.FriendsList.Count);

            foreach(SteamFriend Friend in Client.FriendsList)
            {
                Buffer.WriteUInt32((UInt32)Friend.Status);
                Buffer.WriteBlob(Friend.Username);
                Buffer.WriteUInt64(Friend.XUID);
            }

            Packet.CreatePacket(Packet._TransactionID, 200, Buffer, Client);

            // Clear the buffer.
            Buffer = new redBuffer();

            // Serialize the packet.
            Packet.Serialize(ref Buffer, Client);

            // Send the response.
            SteamServer.Send(Client.ClientID, Buffer.GetBuffer());
        }
开发者ID:RaptorFactor,项目名称:SteamServer,代码行数:26,代码来源:Friends.cs

示例3: GET_GetRecentlyPlayedGames_ByClass

        public void GET_GetRecentlyPlayedGames_ByClass()
        {
            SteamClient client = new SteamClient();
            client.Authenticator = SteamSharp.Authenticators.APIKeyAuthenticator.ForProtectedResource( AccessConstants.APIKey );

            var response = PlayerService.GetRecentlyPlayedGames( client, "76561197960434622" );

            Assert.IsNotNull( response );
            Assert.IsInstanceOfType( response, typeof( PlayerService.PlayedGames ) );

            Assert.IsNotNull( response.TotalCount );

            Assert.IsNotNull( response.Games );

            // Note: This test case will absolutely blow up if Robin goes two weeks without playing a game :)
            Assert.IsTrue( ( response.Games.Count > 0 ) );

            Assert.IsNotNull( response.Games[0] );

            Assert.IsNotNull( response.Games[0].GameID );
            Assert.IsNotNull( response.Games[0].ImgIconURL );
            Assert.IsNotNull( response.Games[0].ImgLogoURL );
            Assert.IsNotNull( response.Games[0].Name );
            Assert.IsNotNull( response.Games[0].PlaytimeForever );
            Assert.IsNotNull( response.Games[0].PlaytimeTwoWeeks );
        }
开发者ID:chaoscode,项目名称:SteamSharp,代码行数:26,代码来源:IPlayerService.cs

示例4: Invoke

        public bool Invoke()
        {
            return Task.Run( async () => {

                try {

                    SteamID targetUser = new SteamID( "76561198129947779" );

                    SteamClient client = new SteamClient();
                    client.Authenticator = UserAuthenticator.ForProtectedResource( AccessConstants.OAuthAccessToken );

                    chatClient.SteamChatConnectionChanged += chatClient_SteamChatConnected;

                    chatClient.SteamChatMessagesReceived += chatClient_SteamChatMessagesReceived;
                    chatClient.SteamChatUserStateChange += chatClient_SteamChatUserStateChange;

                    chatClient.LogOn( client ).Wait();

                    while( true ) {
                        switch( WriteConsole.Prompt( "Command (msg, status): " ) ) {
                            case "msg": await chatClient.SendMessage( targetUser, WriteConsole.Prompt( "Type New Message: " ) ); break;
                            case "dcn": await chatClient.Disconnect(); break;
                        }
                    }

                } catch( Exception e ) {
                    WriteConsole.Error( e.Message + "\n" + e.ToString() );
                    return false;
                }

            } ).Result;
        }
开发者ID:chaoscode,项目名称:SteamSharp,代码行数:32,代码来源:ChatFlow.cs

示例5: Bot

		public Bot(Configuration.BotInfo config, string apiKey, bool debug = false) {
			sql = new Sql();

			Username = config.Username;
			Password = config.Password;
			DisplayName = config.DisplayName;
			Admins = config.Admins;
			id = config.Id;
			this.apiKey = apiKey;

			TradeListener = new ScrapTrade(this);
			TradeListenerInternal = new ExchangeTrade(this);
			TradeListenerAdmin = new AdminTrade(this);

			List<object[]> result = sql.query("SELECT text, response FROM responses");
			foreach (object[] row in result) {
				responses.Add(((string) row[0]).ToLower(), (string) row[1]);
			}

			// Hacking around https
			ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate;

			SteamClient = new SteamClient();
			SteamTrade = SteamClient.GetHandler<SteamTrading>();
			SteamUser = SteamClient.GetHandler<SteamUser>();
			SteamFriends = SteamClient.GetHandler<SteamFriends>();
			queueHandler = new QueueHandler(this);

			SteamClient.Connect();

			while (true) {
				Update();
			}
		}
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:34,代码来源:Bot.cs

示例6: OnConnected

        public void OnConnected(SteamClient.ConnectedCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                this.SetText("Error connecting to Steam: " + callback.Result);
                isRunning = false;
            }
            else
            {

                this.SetText("Connected to Steam Network.");
                if (SteamAuthCode.Text != "")
                {
                    user.LogOn(new SteamUser.LogOnDetails
                    {
                        Username = SteamUserName.Text,
                        Password = SteamPassword.Text,
                        AuthCode = SteamAuthCode.Text
                    });
                }
                else
                {
                    user.LogOn(new SteamUser.LogOnDetails
                    {
                        Username = SteamUserName.Text,
                        Password = SteamPassword.Text
                    });
                }
            }
        }
开发者ID:chaoscode,项目名称:CSharp-RustIO-Client,代码行数:30,代码来源:Form1.cs

示例7: GCClient

        public GCClient()
        {
            SteamClient = new SteamClient();
            SteamClient.AddHandler( new SteamGames() );

            CallbackManager = new CallbackManager( SteamClient );

            SteamUser = SteamClient.GetHandler<SteamUser>();
            SteamGameCoordinator = SteamClient.GetHandler<SteamGameCoordinator>();
            SteamApps = SteamClient.GetHandler<SteamApps>();
            SteamGames = SteamClient.GetHandler<SteamGames>();
            SteamFriends = SteamClient.GetHandler<SteamFriends>();

            new Callback<SteamClient.ConnectedCallback>( OnConnected, CallbackManager );
            new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, CallbackManager );

            new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, CallbackManager );
            new Callback<SteamUser.LoggedOffCallback>( OnLoggedOff, CallbackManager );

            new Callback<SteamApps.LicenseListCallback>( OnLicenseList, CallbackManager );

            new Callback<SteamGameCoordinator.MessageCallback>( OnGCMessage, CallbackManager );

            new JobCallback<SteamApps.AppOwnershipTicketCallback>( OnAppTicket, CallbackManager );
        }
开发者ID:KimimaroTsukimiya,项目名称:DotaBot,代码行数:25,代码来源:GCClient.cs

示例8: GetNextJobIDSetsProcessIDToZero

		public void GetNextJobIDSetsProcessIDToZero()
		{
			var steamClient = new SteamClient();
			var jobID = steamClient.GetNextJobID();

			Assert.Equal(0u, jobID.ProcessID);
		}
开发者ID:JustHev,项目名称:SteamKit,代码行数:7,代码来源:SteamClientFacts.cs

示例9: GET_Add_QueryString_Params

        public void GET_Add_QueryString_Params()
        {
            using( SimulatedServer.Create( AccessConstants.SimulatedServerUrl, QueryString_Echo ) ) {

                // All Params added, GetOrPost & QueryString, should be present in the result set
                SteamClient client = new SteamClient( AccessConstants.SimulatedServerUrl );
                var request = new SteamRequest( "/resource" );

                request.AddParameter( "param1", "1234", ParameterType.GetOrPost );
                request.AddParameter( "param2", "5678", ParameterType.QueryString );

                var response = client.Execute( request );

                Assert.IsNotNull( response.Content );

                string[] temp = response.Content.Split( '|' );

                NameValueCollection coll = new NameValueCollection();
                foreach( string s in temp ) {
                    var split = s.Split( '=' );
                    coll.Add( split[0], split[1] );
                }

                Assert.IsNotNull( coll["param1"] );
                Assert.AreEqual( "1234", coll["param1"] );

                Assert.IsNotNull( coll["param2"] );
                Assert.AreEqual( "5678", coll["param2"] );

            }
        }
开发者ID:chaoscode,项目名称:SteamSharp,代码行数:31,代码来源:UriBuilderTests.cs

示例10: GameCoordinator

        public GameCoordinator(SteamClient steamClient, CallbackManager manager)
        {
            SessionMap = new Dictionary<uint, SessionInfo>();

            // Map gc messages to our callback functions
            MessageMap = new Dictionary<uint, Action<uint, IPacketGCMsg>>
            {
                { (uint)EGCBaseClientMsg.k_EMsgGCClientConnectionStatus, OnConnectionStatus },
                { (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome, OnWelcome },
                { (uint)EGCItemMsg.k_EMsgGCUpdateItemSchema, OnItemSchemaUpdate },
                { (uint)EGCItemMsg.k_EMsgGCClientVersionUpdated, OnVersionUpdate },
                { (uint)EGCBaseMsg.k_EMsgGCSystemMessage, OnSystemMessage },

                // TF2 specific messages
                { k_EMsgGCClientGoodbye, OnConnectionStatus },
                { (uint)EGCItemMsg.k_EMsgGCGoldenWrenchBroadcast, OnWrenchBroadcast },
                { k_EMsgGCTFSpecificItemBroadcast, OnItemBroadcast },
            };

            SteamGameCoordinator = steamClient.GetHandler<SteamGameCoordinator>();

            SessionTimer = new Timer();
            SessionTimer.Interval = TimeSpan.FromSeconds(30).TotalMilliseconds;
            SessionTimer.Elapsed += OnSessionTick;
            SessionTimer.Start();

            manager.Subscribe<SteamGameCoordinator.MessageCallback>(OnGameCoordinatorMessage);
            manager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
            manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
        }
开发者ID:GoeGaming,项目名称:SteamDatabaseBackend,代码行数:30,代码来源:GameCoordinator.cs

示例11: OnConnected

        private void OnConnected(SteamClient.ConnectedCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                GameCoordinator.UpdateStatus(0, callback.Result.ToString());

                IRC.Instance.SendEmoteAnnounce("failed to connect: {0}", callback.Result);

                Log.WriteInfo("Steam", "Could not connect: {0}", callback.Result);

                return;
            }

            GameCoordinator.UpdateStatus(0, EResult.NotLoggedOn.ToString());

            Log.WriteInfo("Steam", "Connected, logging in to cellid {0}...", LocalConfig.CellID);

            byte[] sentryHash = null;

            if (LocalConfig.Sentry != null)
            {
                sentryHash = CryptoHelper.SHAHash(LocalConfig.Sentry);
            }

            Steam.Instance.User.LogOn(new SteamUser.LogOnDetails
            {
                Username = Settings.Current.Steam.Username,
                Password = Settings.Current.Steam.Password,
                CellID = LocalConfig.CellID,
                AuthCode = AuthCode,
                SentryFileHash = sentryHash
            });
        }
开发者ID:qyh214,项目名称:SteamDatabaseBackend,代码行数:33,代码来源:Connection.cs

示例12: LogIn

        static void LogIn()
        {
            steamClient = new SteamClient();
            callbackManager = new CallbackManager(steamClient);
            steamUser = steamClient.GetHandler<SteamUser>();
            steamFriends = steamClient.GetHandler<SteamFriends>();
            steamTrading = steamClient.GetHandler<SteamTrading>();
            new Callback<SteamClient.ConnectedCallback>(OnConnect,callbackManager);
            new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, callbackManager);
            new Callback<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth, callbackManager);
            new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, callbackManager);
            new Callback<SteamUser.AccountInfoCallback>(OnAccountInfo, callbackManager);
            new Callback<SteamFriends.FriendMsgCallback>(OnChatMessage, callbackManager);
            new Callback<SteamFriends.FriendsListCallback>(OnFriendInvite, callbackManager);
            new Callback<SteamTrading.TradeProposedCallback>(OnTradeOffer, callbackManager);
            new Callback<SteamTrading.SessionStartCallback>(OnTradeWindow, callbackManager);
            new Callback<SteamTrading.TradeResultCallback>(OnTradeResult, callbackManager);

            isRunning = true;

            Console.WriteLine("Attempting to connect to steam...");

            steamClient.Connect();

            while(isRunning)
            {
                callbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
            }
            Console.ReadKey();
        }
开发者ID:Hydromaniaccat,项目名称:SteamBot,代码行数:30,代码来源:Program.cs

示例13: Steam

        public Steam()
        {
            Client = new SteamClient();

            User = Client.GetHandler<SteamUser>();
            Apps = Client.GetHandler<SteamApps>();
            Friends = Client.GetHandler<SteamFriends>();
            UserStats = Client.GetHandler<SteamUserStats>();

            CallbackManager = new CallbackManager(Client);

            Client.AddHandler(new ReadMachineAuth());

            new Connection(CallbackManager);
            new PICSProductInfo(CallbackManager);
            new PICSTokens(CallbackManager);
            new LicenseList(CallbackManager);
            new WebAuth(CallbackManager);
            new FreeLicense(CallbackManager);

            if (!Settings.IsFullRun)
            {
                new AccountInfo(CallbackManager);
                new ClanState(CallbackManager);
                new ChatMemberInfo(CallbackManager);
                new GameCoordinator(Client, CallbackManager);

                new Watchdog();
            }

            PICSChanges = new PICSChanges(CallbackManager);
            DepotProcessor = new DepotProcessor(Client, CallbackManager);

            IsRunning = true;
        }
开发者ID:TheFighter,项目名称:SteamDatabaseBackend,代码行数:35,代码来源:Steam.cs

示例14: SteamBot

        public SteamBot(string newUser, string newPass)
        {
            // Bot user and password
            user = newUser;
            pass = newPass;

            // create our steamclient instance
            steamClient = new SteamClient( System.Net.Sockets.ProtocolType.Tcp );
            // 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>();
            // get the steam friends handler, which is used for interacting with friends on the network after logging on
            steamFriends = steamClient.GetHandler<SteamFriends>();

            // 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
            new Callback<SteamClient.ConnectedCallback>( OnConnected, manager );
            new Callback<SteamClient.DisconnectedCallback>( OnDisconnected, manager );

            new Callback<SteamUser.LoggedOnCallback>( OnLoggedOn, manager );

            // we use the following callbacks for friends related activities
            new Callback<SteamUser.AccountInfoCallback>( OnAccountInfo, manager );
            new Callback<SteamFriends.FriendsListCallback>( OnFriendsList, manager );
            new Callback<SteamFriends.FriendMsgCallback> (OnFriendMessage, manager);

            // initiate the connection
            steamClient.Connect();

            // Make sure the main loop runs
            isRunning = true;
        }
开发者ID:natehak,项目名称:SteamGroupChatBot,代码行数:35,代码来源:SteamBot.cs

示例15: OnConnected

        private void OnConnected(SteamClient.ConnectedCallback callback)
        {
            if (callback.Result != EResult.OK)
            {
                _checkResult = ECheckResult.ConnectFailed;
                _isRunning = false;
                return;
            }

            byte[] sentryHash = null;
            if (File.Exists(_sentryLoc))
            {
                byte[] sentryFile = File.ReadAllBytes(_sentryLoc);
                sentryHash = CryptoHelper.SHAHash(sentryFile);
            }
            else if (_operation == EOperationType.CheckSentry || _operation == EOperationType.AddToSentry)
            {
                _checkResult = ECheckResult.SentryMissing;
                _isRunning = false;
                return;
            }

            _steamUser.LogOn(new SteamUser.LogOnDetails
            {
                Username = _username,
                Password = _password,
                AuthCode = _authCode,
                TwoFactorCode = _twoFactorAuth,
                SentryFileHash = sentryHash,
            });
        }
开发者ID:Shravan2x,项目名称:SteamSentryTool,代码行数:31,代码来源:SentryOperator.cs


注:本文中的SteamClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。