Example #1
0
        public Client(uint appId)
        {
            Instance = this;
            native   = new Interop.NativeInterface();

            //
            // Get other interfaces
            //
            if (!native.InitClient(this))
            {
                native.Dispose();
                native   = null;
                Instance = null;
                return;
            }

            //
            // Setup interfaces that client and server both have
            //
            SetupCommonInterfaces();

            //
            // Client only interfaces
            //
            Voice             = new Voice(this);
            ServerList        = new ServerList(this);
            LobbyList         = new LobbyList(this);
            App               = new App(this);
            Stats             = new Stats(this);
            Achievements      = new Achievements(this);
            MicroTransactions = new MicroTransactions(this);
            User              = new User(this);
            RemoteStorage     = new RemoteStorage(this);

            Workshop.friends = Friends;

            Stats.UpdateStats();

            //
            // Cache common, unchanging info
            //
            AppId              = appId;
            Username           = native.friends.GetPersonaName();
            SteamId            = native.user.GetSteamID();
            BetaName           = native.apps.GetCurrentBetaName();
            OwnerSteamId       = native.apps.GetAppOwner();
            InstallFolder      = new DirectoryInfo(native.apps.GetAppInstallDir(AppId));
            BuildId            = native.apps.GetAppBuildId();
            CurrentLanguage    = native.apps.GetCurrentGameLanguage();
            AvailableLanguages = native.apps.GetAvailableGameLanguages().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // TODO: Assumed colon separated



            //
            // Run update, first call does some initialization
            //
            Update();
        }
Example #2
0
        /// <summary>
        /// Call when finished to shut down the Steam client.
        /// </summary>
        public override void Dispose()
        {
            if (Voice != null)
            {
                Voice.Dispose();
                Voice = null;
            }

            if (ServerList != null)
            {
                ServerList.Dispose();
                ServerList = null;
            }

            if (App != null)
            {
                App.Dispose();
                App = null;
            }

            if (Stats != null)
            {
                Stats.Dispose();
                Stats = null;
            }

            if (Achievements != null)
            {
                Achievements.Dispose();
                Achievements = null;
            }

            if (MicroTransactions != null)
            {
                MicroTransactions.Dispose();
                MicroTransactions = null;
            }

            if (User != null)
            {
                User.Dispose();
                User = null;
            }

            if (RemoteStorage != null)
            {
                RemoteStorage.Dispose();
                RemoteStorage = null;
            }

            if (Instance == this)
            {
                Instance = null;
            }

            base.Dispose();
        }
        /// <summary>
        /// Call when finished to shut down the Steam client.
        /// </summary>
        public override void Dispose()
        {
            if (Voice != null)
            {
                Voice.Dispose();
                Voice = null;
            }

            if (ServerList != null)
            {
                ServerList.Dispose();
                ServerList = null;
            }

            base.Dispose();
        }
Example #4
0
        public Client(uint appId)
        {
            native = new Interop.NativeInterface();

            //
            // Get other interfaces
            //
            if (!native.InitClient(this))
            {
                native.Dispose();
                native = null;
                return;
            }

            //
            // Setup interfaces that client and server both have
            //
            SetupCommonInterfaces();

            //
            // Client only interfaces
            //
            Voice      = new Voice(this);
            ServerList = new ServerList(this);
            App        = new App(this);

            Workshop.friends = Friends;


            //
            // Cache common, unchanging info
            //
            AppId         = appId;
            Username      = native.friends.GetPersonaName();
            SteamId       = native.user.GetSteamID();
            BetaName      = native.apps.GetCurrentBetaName();
            OwnerSteamId  = native.apps.GetAppOwner();
            InstallFolder = new DirectoryInfo(native.apps.GetAppInstallDir(AppId));
            BuildId       = native.apps.GetAppBuildId();

            //
            // Run update, first call does some initialization
            //
            Update();
        }
            internal void StartCustomQuery()
            {
                if (ServerList == null)
                {
                    return;
                }

                int blockSize = 16;
                int Pointer   = 0;

                while (true)
                {
                    var sublist = ServerList.Skip(Pointer).Take(blockSize);

                    if (sublist.Count() == 0)
                    {
                        break;
                    }

                    Pointer += sublist.Count();

                    var filter = new Filter();
                    filter.Add("or", sublist.Count().ToString());

                    foreach (var server in sublist)
                    {
                        filter.Add("gameaddr", server);
                    }

                    filter.Start();
                    var id = client.native.servers.RequestInternetServerList(client.AppId, filter.NativeArray, (uint)filter.Count, IntPtr.Zero);
                    filter.Free();

                    AddRequest(id);
                }

                ServerList = null;
            }
        public Client(uint appId) : base(appId)
        {
            if (Instance != null)
            {
                throw new System.Exception("Only one Facepunch.Steamworks.Client can exist - dispose the old one before trying to create a new one.");
            }

            Instance = this;
            native   = new Interop.NativeInterface();

            //
            // Get other interfaces
            //
            if (!native.InitClient(this))
            {
                native.Dispose();
                native   = null;
                Instance = null;
                return;
            }

            //
            // Setup interfaces that client and server both have
            //
            SetupCommonInterfaces();

            //
            // Register Callbacks
            //

            SteamNative.Callbacks.RegisterCallbacks(this);

            //
            // Client only interfaces
            //
            Voice             = new Voice(this);
            ServerList        = new ServerList(this);
            LobbyList         = new LobbyList(this);
            App               = new App(this);
            Stats             = new Stats(this);
            Achievements      = new Achievements(this);
            MicroTransactions = new MicroTransactions(this);
            User              = new User(this);
            RemoteStorage     = new RemoteStorage(this);

            Workshop.friends = Friends;

            Stats.UpdateStats();

            //
            // Cache common, unchanging info
            //
            AppId        = appId;
            Username     = native.friends.GetPersonaName();
            SteamId      = native.user.GetSteamID();
            BetaName     = native.apps.GetCurrentBetaName();
            OwnerSteamId = native.apps.GetAppOwner();
            var appInstallDir = native.apps.GetAppInstallDir(AppId);

            if (!String.IsNullOrEmpty(appInstallDir) && Directory.Exists(appInstallDir))
            {
                InstallFolder = new DirectoryInfo(appInstallDir);
            }
            BuildId            = native.apps.GetAppBuildId();
            CurrentLanguage    = native.apps.GetCurrentGameLanguage();
            AvailableLanguages = native.apps.GetAvailableGameLanguages().Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); // TODO: Assumed colon separated

            //
            // Run update, first call does some initialization
            //
            Update();
        }