Exemplo n.º 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();
        }
Exemplo n.º 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));
                }
            });
        }
Exemplo n.º 3
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();
        }
Exemplo n.º 4
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);
 }
Exemplo n.º 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);
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 7
0
 internal AppChangesCallback(SteamClient client, CMsgClientAppInfoChanges msg)
     : base(client)
Exemplo n.º 8
0
 internal StatusReplyCallback(SteamClient client, CMsgGSStatusReply reply)
     : base(client)
Exemplo n.º 9
0
 internal TicketAuthCallback(SteamClient client, CMsgClientTicketAuthComplete tickAuth)
     : base(client)
Exemplo n.º 10
0
 internal ConnectedCallback(SteamClient client, MsgChannelEncryptResult result)
     : this(client, result.Result)
Exemplo n.º 11
0
 internal ProfileInfoCallback(SteamClient client, CMsgClientFriendProfileInfoResponse response)
     : base(client)
Exemplo n.º 12
0
 internal ChatMemberInfoCallback(SteamClient client, MsgClientChatMemberInfo msg, byte[] payload)
     : base(client)
Exemplo n.º 13
0
 internal ChatInviteCallback(SteamClient client, CMsgClientChatInvite invite)
     : base(client)
Exemplo n.º 14
0
 internal FriendMsgCallback(SteamClient client, CMsgClientFriendMsgIncoming msg)
     : base(client)
Exemplo n.º 15
0
 internal ChatEnterCallback(SteamClient client, MsgClientChatEnter msg)
     : base(client)
Exemplo n.º 16
0
 internal PersonaStateCallback(SteamClient client, CMsgClientPersonaState.Friend friend)
     : base(client)
Exemplo n.º 17
0
 internal PackageInfoCallback(SteamClient client, CMsgClientPackageInfoResponse msg)
     : base(client)
Exemplo n.º 18
0
 internal AppInfoCallback(SteamClient client, CMsgClientAppInfoResponse msg)
     : base(client)
Exemplo n.º 19
0
 internal AppOwnershipTicketCallback(SteamClient client, CMsgClientGetAppOwnershipTicketResponse msg)
     : base(client)
Exemplo n.º 20
0
 internal LicenseListCallback(SteamClient client, CMsgClientLicenseList msg)
     : base(client)
Exemplo n.º 21
0
 internal FriendsListCallback(SteamClient client, CMsgClientFriendsList msg)
     : base(client)
Exemplo n.º 22
0
 internal DepotKeyCallback(SteamClient client, CMsgClientGetDepotDecryptionKeyResponse msg)
     : base(client)
Exemplo n.º 23
0
 internal FriendAddedCallback(SteamClient client, CMsgClientAddFriendResponse msg)
     : base(client)
Exemplo n.º 24
0
 internal GameConnectTokensCallback(SteamClient client, CMsgClientGameConnectTokens msg)
     : base(client)
Exemplo n.º 25
0
 internal ChatMsgCallback(SteamClient client, MsgClientChatMsg msg, byte[] payload)
     : base(client)
Exemplo n.º 26
0
 internal VACStatusCallback(SteamClient client, MsgClientVACBanStatus msg, byte[] payload)
     : base(client)
Exemplo n.º 27
0
 internal ChatActionResultCallback(SteamClient client, MsgClientChatActionResult result)
     : base(client)
Exemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CallbackManager"/> class.
        /// </summary>
        /// <param name="client">The <see cref="SteamClient"/> instance to handle the callbacks of.</param>
        public CallbackManager(SteamClient client)
        {
            registeredCallbacks = new List <Internal.CallbackBase>();

            this.client = client;
        }
Exemplo n.º 29
0
 internal QueryCallback(SteamClient client, CMsgGMSClientServerQueryResponse msg)
     : base(client)
Exemplo n.º 30
0
 internal IgnoreFriendCallback(SteamClient client, MsgClientSetIgnoreFriendResponse response)
     : base(client)