Beispiel #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();
        }
Beispiel #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));
                }
            });
        }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JobCallback&lt;TCall&gt;"/> class.
 /// </summary>
 /// <param name="func">The function to call when a job based callback of type TCall arrives.</param>
 /// <param name="mgr">The <see cref="CallbackManager"/> that is responsible for the routing of callbacks to this handler, or <c>null</c> if the callback will be manually registered.</param>
 public JobCallback(Action <TCall, JobID> func, CallbackManager mgr = null)
     : this(func, mgr, JobID.Invalid)
 {
 }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Callback&lt;TCall&gt;"/> class.
        /// </summary>
        /// <param name="func">The function to call when a callback of type TCall arrives.</param>
        /// <param name="mgr">The <see cref="CallbackManager"/> that is responsible for the routing of callbacks to this handler, or null if the callback will be registered manually.</param>
        public Callback(Action <TCall> func, CallbackManager mgr = null)
        {
            this.OnRun = func;

            AttachTo(mgr);
        }
Beispiel #5
0
 public Subscription(Internal.CallbackBase call, CallbackManager manager)
 {
     this.manager = manager;
     this.call    = call;
 }