public bool Initialize(long appId)
        {
            if (appId != 0)
            {
                Environment.SetEnvironmentVariable("SteamAppId", appId.ToString(CultureInfo.InvariantCulture));
            }

            if (Steam.GetInstallPath() == null)
            {
                return(false);
            }

            if (Steam.Load() == false)
            {
                return(false);
            }

            this.SteamClient = Steam.CreateInterface <Wrappers.SteamClient009>("SteamClient009");
            if (this.SteamClient == null)
            {
                return(false);
            }

            this._Pipe = this.SteamClient.CreateSteamPipe();
            if (this._Pipe == 0)
            {
                return(false);
            }

            this._User = this.SteamClient.ConnectToGlobalUser(this._Pipe);
            if (this._User == 0)
            {
                return(false);
            }

            this.SteamUtils = this.SteamClient.GetSteamUtils004(this._Pipe);
            if (appId > 0 && this.SteamUtils.GetAppId() != (uint)appId)
            {
                return(false);
            }

            this.SteamUser      = this.SteamClient.GetSteamUser012(this._User, this._Pipe);
            this.SteamUserStats = this.SteamClient.GetSteamUserStats006(this._User, this._Pipe);
            this.SteamApps001   = this.SteamClient.GetSteamApps001(this._User, this._Pipe);
            this.SteamApps003   = this.SteamClient.GetSteamApps003(this._User, this._Pipe);
            return(true);
        }
Пример #2
0
        public void Initialize(long appId)
        {
            if (string.IsNullOrEmpty(Steam.GetInstallPath()) == true)
            {
                throw new ClientInitializeException(ClientInitializeFailure.GetInstallPath, "failed to get Steam install path");
            }

            if (appId != 0)
            {
                Environment.SetEnvironmentVariable("SteamAppId", appId.ToString(CultureInfo.InvariantCulture));
            }

            if (Steam.Load() == false)
            {
                throw new ClientInitializeException(ClientInitializeFailure.Load, "failed to load SteamClient");
            }

            this.SteamClient = Steam.CreateInterface <Wrappers.SteamClient018>("SteamClient018");
            if (this.SteamClient == null)
            {
                throw new ClientInitializeException(ClientInitializeFailure.CreateSteamClient, "failed to create ISteamClient018");
            }

            this._Pipe = this.SteamClient.CreateSteamPipe();
            if (this._Pipe == 0)
            {
                throw new ClientInitializeException(ClientInitializeFailure.CreateSteamPipe, "failed to create pipe");
            }

            this._User = this.SteamClient.ConnectToGlobalUser(this._Pipe);
            if (this._User == 0)
            {
                throw new ClientInitializeException(ClientInitializeFailure.ConnectToGlobalUser, "failed to connect to global user");
            }

            this.SteamUtils = this.SteamClient.GetSteamUtils004(this._Pipe);
            if (appId > 0 && this.SteamUtils.GetAppId() != (uint)appId)
            {
                throw new ClientInitializeException(ClientInitializeFailure.AppIdMismatch, "appID mismatch");
            }

            this.SteamUser      = this.SteamClient.GetSteamUser012(this._User, this._Pipe);
            this.SteamUserStats = this.SteamClient.GetSteamUserStats006(this._User, this._Pipe);
            this.SteamApps001   = this.SteamClient.GetSteamApps001(this._User, this._Pipe);
            this.SteamApps008   = this.SteamClient.GetSteamApps008(this._User, this._Pipe);
        }