Ejemplo n.º 1
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();
        }