Пример #1
0
        private static bool ConnectToSteam()
        {
            var    steamError = new TSteamError();
            string errorText  = "";

            if (!Steamworks.Load(true))
            {
                errorText = "Steamworks failed to load.";
                Console.WriteLine(errorText);
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                errorText = "Steam startup failed. Is Steam running?";
                Console.WriteLine(errorText);
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                errorText = "Failed to create user pipe.";
                Console.WriteLine(errorText);
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                errorText = "Failed to connect to global user.";
                Console.WriteLine(errorText);
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Пример #2
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                lblError.Text = "Steamworks failed to load.";
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                lblError.Text = "Пожалуйста, включите программу Steam.";
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                lblError.Text = "Failed to create user pipe.";
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                lblError.Text = "Failed to connect to global user.";
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            _clientUser    = _clientEngine.GetIClientUser <IClientUser>(_user, _pipe);
            return(true);
        }
Пример #3
0
        private bool connectToSteam()
        {
            var steamError = new TSteamError();

            if (!Steamworks.Load(true))
            {
                throw new SteamException("Steamworks failed to load.");
                return(false);
            }

            _steam006 = Steamworks.CreateSteamInterface <ISteam006>();
            if (_steam006.Startup(0, ref steamError) == 0)
            {
                throw new SteamException("Steam startup failed.");
                return(false);
            }

            _steamClient012 = Steamworks.CreateInterface <ISteamClient012>();
            _clientEngine   = Steamworks.CreateInterface <IClientEngine>();

            _pipe = _steamClient012.CreateSteamPipe();
            if (_pipe == 0)
            {
                throw new SteamException("Failed to create a pipe.");
                return(false);
            }

            _user = _steamClient012.ConnectToGlobalUser(_pipe);
            if (_user == 0 || _user == -1)
            {
                throw new SteamException("Failed to connect to global user.");
                return(false);
            }

            _clientBilling = _clientEngine.GetIClientBilling <IClientBilling>(_user, _pipe);
            return(true);
        }