Пример #1
0
        public SteamClient(SteamCredentials credentials, SteamAuthenticationCodesProvider codesProvider, SteamAuthenticationFilesProvider authenticationProvider)
        {
            Credentials             = credentials ?? throw new ArgumentNullException(nameof(credentials));
            _codesProvider          = codesProvider;
            _authenticationProvider = authenticationProvider;
            InternalClient          = new SteamKit.SteamClient();

            _cancellationTokenSource = new CancellationTokenSource();
            CallbackManager          = new SteamKit.CallbackManager(InternalClient);

            _steamUser = InternalClient.GetHandler <SteamKit.SteamUser>();
            _steamApps = InternalClient.GetHandler <SteamKit.SteamApps>();

            Task.Run(async() => await CallbackManagerHandler());

            CallbackManager.Subscribe <SteamKit.SteamClient.ConnectedCallback>(OnConnected);
            CallbackManager.Subscribe <SteamKit.SteamClient.DisconnectedCallback>(OnDisconnected);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOnCallback>(OnLoggedOn);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoggedOffCallback>(OnLoggedOff);
            CallbackManager.Subscribe <SteamKit.SteamApps.LicenseListCallback>(OnLicenseList);
            CallbackManager.Subscribe <SteamKit.SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            CallbackManager.Subscribe <SteamKit.SteamUser.LoginKeyCallback>(OnLoginKey);

            InternalClient.Connect();
        }
Пример #2
0
        public void LogIn(string username, string password)
        {
            Username = username;
            Password = password;

            client      = new SK.SteamClient();
            CurrentUser = new SteamUser();

            manager = new SK.CallbackManager(client);

            steamUser = client.GetHandler <SK.SteamUser>();
            community = client.GetHandler <SK.SteamFriends>();

            manager.Subscribe <SK.SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe <SK.SteamClient.DisconnectedCallback>(OnDisconnected);

            manager.Subscribe <SK.SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe <SK.SteamUser.LoggedOffCallback>(OnLoggedOff);

            manager.Subscribe <SK.SteamUser.AccountInfoCallback>(OnAccountInfo);
            manager.Subscribe <SK.SteamFriends.FriendsListCallback>(OnCommunityLoaded);
            manager.Subscribe <SK.SteamFriends.PersonaStateCallback>(OnPersonaState);
            manager.Subscribe <SK.SteamFriends.FriendAddedCallback>(OnFriendAdded);

            IsConnected = true;
            client.Connect();

            Task.Run(() =>
            {
                while (IsConnected)
                {
                    manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
                }
            });
        }
Пример #3
0
 public SteamApiClient()
 {
     steamClient = new SteamKit2.SteamClient();
     manager     = new CallbackManager(steamClient);
     steamUser   = steamClient.GetHandler <SteamUser>();
     steamApps   = steamClient.GetHandler <SteamApps>();
     manager.Subscribe <SteamKit2.SteamClient.ConnectedCallback>(onConnected);
     manager.Subscribe <SteamKit2.SteamClient.DisconnectedCallback>(onDisconnected);
     manager.Subscribe <SteamUser.LoggedOnCallback>(onLoggedOn);
     manager.Subscribe <SteamUser.LoggedOffCallback>(onLoggedOff);
 }
Пример #4
0
        public SteamClient(ILogger logger)
        {
            steamClient     = new SteamKit2.SteamClient();
            manager         = new CallbackManager(steamClient);
            steamUser       = steamClient.GetHandler <SteamUser>();
            gameCoordinator = steamClient.GetHandler <SteamGameCoordinator>();

            this.logger = logger;

            SubscribeOnCallbacks();
        }
Пример #5
0
        private void InitializeClient()
        {
            // client/manager creation
            Client  = new SteamClient();
            Manager = new CallbackManager(Client);

            _user = Client.GetHandler <SteamUser>();
            _apps = Client.GetHandler <SteamApps>();

            Client.AddHandler(new SteamTicketAuth());

            // subscriptions
            Manager.Subscribe <SteamClient.DisconnectedCallback>(OnDisconnected);
            Manager.Subscribe <SteamClient.ConnectedCallback>(OnConnected);
            Manager.Subscribe <SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            Manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);


            // internal subs
            Manager.Subscribe <SteamApps.GameConnectTokensCallback>(OnGcTokens);
        }
Пример #6
0
        public void Connect()
        {
            // create our steamclient instance
            _steamClient = new SteamKit2.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>();
            _steamApps    = _steamClient.GetHandler <SteamApps>();
            _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
            _manager.Subscribe <SteamKit2.SteamClient.ConnectedCallback>(OnConnected);
            _manager.Subscribe <SteamKit2.SteamClient.DisconnectedCallback>(OnDisconnected);

            _manager.Subscribe <SteamUser.LoggedOnCallback>(OnLoggedOn);
            _manager.Subscribe <SteamUser.LoggedOffCallback>(OnLoggedOff);

            _manager.Subscribe <SteamApps.AppOwnershipTicketCallback>(OnAppOwnershipTicketCallback);
            _manager.Subscribe <SteamApps.GameConnectTokensCallback>(OnGameConnectTokens);
            _steamClient.AddHandler(new Handler <SteamPlayer>(OnMessage));

            _isRunning = true;

            ConsoleSystem.Log("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));
            }
        }