Beispiel #1
0
        /// <summary>
        /// Callback that is called directly from native code
        /// </summary>
        /// <param name="instanceId"></param>
        /// <param name="name"></param>
        /// <param name="score"></param>
        /// <param name="timePlayed"></param>
        private static void AddPlayerToListCallback(uint instanceId, IntPtr name, int score, float timePlayed)
        {
            try
            {
                var target = MatchmakingServers.PlayersResponse[instanceId];
                target.addPlayerToList.Add(new CachedResponses(NativeHelpers.ToStringUtf8(name), score, timePlayed));
            }
            catch (Exception e)
            {
                // If we get a null reference exception it means that either the Steam.Instance,
                // Steam.Instance.MatchmakingServers,
                // Steam.Instance.MatchmakingServers.PingResponse,
                // target or target.serverResponded is null.
                //
                // Either way, this should not happen during correct usage. But since we can't
                // throw an exception as this method is called from native code, we try to save it.

                try
                {
                    MatchmakingServers.SaveException(e);
                }
                catch (Exception)
                {
                    // If anything goes wrong while saving the exception, just ignore it.
                }
            }
        }
Beispiel #2
0
        private void Startup(uint ip, ushort steamPort, ushort gamePort, ushort queryPort, ServerMode serverMode, string versionString)
        {
            if (NativeHelpers.ServicesGameServer_GetSteamLoadStatus() == LoadStatus.NotLoaded)
            {
                // Only startup the native parts if they are not loaded yet
                if (!NativeMethods.ServicesGameServer_Startup(Constants.VersionInfo.InterfaceID, ip, steamPort, gamePort, queryPort, (int)serverMode, versionString))
                {
                    // Setup failed!
                    Instance = null;
                    ErrorCodes error = NativeHelpers.ServicesGameServer_GetErrorCode();
                    if (error == ErrorCodes.InvalidInterfaceVersion)
                    {
                        Error.ThrowError(ErrorCodes.InvalidInterfaceVersion,
                                         NativeMethods.ServicesGameServer_GetInterfaceVersion(), Constants.VersionInfo.InterfaceID);
                    }
                    else
                    {
                        Error.ThrowError(error);
                    }
                }
            }

            serviceJobs = new JobManager();
            serviceJobs.AddJob(new DelegateJob(() => RegisterManagedCallback(), () => RemoveManagedCallback()));
            serviceJobs.AddJob(new DelegateJob(() => gameServer      = new GameServer(), () => gameServer.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => gameServerStats = new GameServerStats(), () => gameServerStats.ReleaseManagedResources()));

            serviceJobs.RunCreateJobs();
        }
        private void Startup()
        {
            if (NativeHelpers.Services_GetSteamLoadStatus() == LoadStatus.NotLoaded)
            {
                // Only startup the native parts if they are not loaded yet
                if (!NativeMethods.Services_Startup(Constants.VersionInfo.InterfaceID))
                {
                    // Setup failed!
                    Instance = null;
                    ErrorCodes error = NativeHelpers.Services_GetErrorCode();
                    if (error == ErrorCodes.InvalidInterfaceVersion)
                    {
                        Error.ThrowError(ErrorCodes.InvalidInterfaceVersion,
                                         NativeMethods.Services_GetInterfaceVersion(), Constants.VersionInfo.InterfaceID);
                    }
                    else
                    {
                        Error.ThrowError(error);
                    }
                }
            }

            AppID = new SteamTypes.AppID(NativeMethods.Services_GetAppID());

            serviceJobs = new JobManager();
            serviceJobs.AddJob(new DelegateJob(() => RegisterManagedCallback(), () => RemoveManagedCallback()));
            serviceJobs.AddJob(new DelegateJob(() => cloud              = new Cloud(), () => cloud.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => stats              = new Stats(), () => stats.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => user               = new User(), () => user.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => friends            = new Friends(), () => friends.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => matchmaking        = new MatchMaking(), () => matchmaking.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => matchmakingServers = new MatchmakingServers(), () => matchmakingServers.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => networking         = new Networking(), () => networking.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => utils              = new Utils(), () => utils.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => apps               = new Apps(), () => apps.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => http               = new HTTP(), () => http.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => screenshots        = new Screenshots(), () => screenshots.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => ugc             = new UGC(), () => ugc.ReleaseManagedResources()));
            serviceJobs.AddJob(new DelegateJob(() => steamcontroller = new SteamController(), () => steamcontroller.ReleaseManagedResources()));

            hmd = new Hmd();

            serviceJobs.RunCreateJobs();
        }