public NodeInstanceController(AutomaticaContext db, INotifyDriver notifyDriver, INodeInstanceCache nodeInstanceCache, ICoreServer server)
     : base(db)
 {
     _notifyDriver      = notifyDriver;
     _nodeInstanceCache = nodeInstanceCache;
     _server            = server;
 }
Exemple #2
0
        public AutomaticUpdate(ICoreServer server, IConfiguration config, ICloudApi api)
        {
            _server = server;
            _config = config;
            _api    = api;

            _timer.Elapsed += _timer_Elapsed;
        }
Exemple #3
0
 public PluginDownloader(Plugin plugin, bool install, ICloudApi cloudApi, IHubContext <UpdateHub> updateHub, ICoreServer coreServer, bool restartOnUpdate = true)
 {
     _plugin          = plugin;
     _install         = install;
     _api             = cloudApi;
     _updateHub       = updateHub;
     _coreServer      = coreServer;
     _restartOnUpdate = restartOnUpdate;
 }
Exemple #4
0
 /// <summary>
 /// Creates a new <see cref="LoginHandler"/> instance.
 /// </summary>
 /// <param name="logger">Logger.</param>
 /// <param name="loginConfiguration">Login server configuration.</param>
 /// <param name="loginServer">Login server instance.</param>
 /// <param name="database">Database service.</param>
 /// <param name="coreServer">Core server.</param>
 /// <param name="loginPacketFactory">Login server packet factory.</param>
 public LoginHandler(ILogger <LoginHandler> logger, IOptions <LoginConfiguration> loginConfiguration, ILoginServer loginServer, IRhisisDatabase database, ICoreServer coreServer, ILoginPacketFactory loginPacketFactory)
 {
     _logger             = logger;
     _loginConfiguration = loginConfiguration.Value;
     _loginServer        = loginServer;
     _database           = database;
     _coreServer         = coreServer;
     _loginPacketFactory = loginPacketFactory;
 }
Exemple #5
0
        public UpdateHub(ICloudApi api, IHubContext <UpdateHub> updateHub, ICoreServer coreServer, IPluginLoader loader, IHubSemaphoreFactory semaphoreFactory)
        {
            _api        = api;
            _updateHub  = updateHub;
            _coreServer = coreServer;
            _loader     = loader;


            _semaphore = semaphoreFactory.GetSemaphore(nameof(UpdateHub));
        }
 public RulesController(AutomaticaContext db, IRuleDataHandler ruleDataHandler, ILogicCacheFacade logicCacheFacade, IConfiguration config,
                        INotifyDriver notifyDriver, INodeInstanceCache nodeInstanceCache, ICoreServer coreServer)
     : base(db)
 {
     _ruleDataHandler   = ruleDataHandler;
     _logicCacheFacade  = logicCacheFacade;
     _config            = config;
     _notifyDriver      = notifyDriver;
     _nodeInstanceCache = nodeInstanceCache;
     _coreServer        = coreServer;
 }
Exemple #7
0
 public NodeInstanceV2Controller(
     AutomaticaContext dbContext,
     INodeInstanceCache nodeInstanceCache,
     INotifyDriver notifyDriver,
     ICoreServer coreServer,
     INodeTemplateCache templateCache,
     IDriverNodesStore driverNodeStore) : base(dbContext)
 {
     _nodeInstanceCache = nodeInstanceCache;
     _notifyDriver      = notifyDriver;
     _coreServer        = coreServer;
     _templateCache     = templateCache;
     _driverNodeStore   = driverNodeStore;
 }
Exemple #8
0
 public SettingsController(AutomaticaContext dbContext, ICoreServer coreServer) : base(dbContext)
 {
     _coreServer = coreServer;
 }
 public PluginsController(AutomaticaContext dbContext, ICloudApi api, ICoreServer coreServer) : base(dbContext)
 {
     _api        = api;
     _coreServer = coreServer;
 }
Exemple #10
0
 public UpdateHub(ICloudApi api, IHubContext <UpdateHub> updateHub, ICoreServer coreServer)
 {
     _api        = api;
     _updateHub  = updateHub;
     _coreServer = coreServer;
 }
        public static StartupSequenceResult Start(string[] args)
        {
            StartupTrace.WriteLine("Protected Startup: Execution of protected startup has begun");

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var kernel = new StandardKernel();

            kernel.Bind <IRawLaunchArguments>()
            .ToMethod(x => new DefaultRawLaunchArguments(args))
            .InSingletonScope();

            Func <System.Reflection.Assembly, Type[]> TryGetTypes = assembly =>
            {
                try
                {
                    return(assembly.GetTypes());
                }
                catch
                {
                    return(new Type[0]);
                }
            };

            StartupTrace.WriteLine("Protected Startup: Scanning for implementations of IGameConfiguration");

            var assemblies = AppDomain.CurrentDomain.GetAssemblies();
            var typeSource = new List <Type>();

            foreach (var assembly in assemblies)
            {
                typeSource.AddRange(assembly.GetCustomAttributes(false).OfType <ConfigurationAttribute>().Select(x => x.GameConfigurationOrServerClass));
            }

            StartupTrace.TimingEntries["scanForConfigurationAttributes"] = stopwatch.Elapsed;
            stopwatch.Restart();

            if (typeSource.Count == 0)
            {
                // Scan all types to find implementors of IGameConfiguration
                typeSource.AddRange(from assembly in AppDomain.CurrentDomain.GetAssemblies()
                                    from type in TryGetTypes(assembly)
                                    select type);

                StartupTrace.TimingEntries["scanForGameConfigurationImplementations"] = stopwatch.Elapsed;
                stopwatch.Restart();
            }

            // Search the application domain for implementations of
            // the IGameConfiguration.
            var gameConfigurations = new List <IGameConfiguration>();

            foreach (var type in typeSource)
            {
                if (typeof(IGameConfiguration).IsAssignableFrom(type) &&
                    !type.IsInterface && !type.IsAbstract)
                {
                    gameConfigurations.Add(Activator.CreateInstance(type) as IGameConfiguration);
                }
            }

            StartupTrace.WriteLine("Protected Startup: Found " + gameConfigurations.Count + " implementations of IGameConfiguration");

#if CAN_RUN_DEDICATED_SERVER
            StartupTrace.WriteLine("Protected Startup: Scanning for implementations of IServerConfiguration");

            // Search the application domain for implementations of
            // the IServerConfiguration.
            var serverConfigurations = new List <IServerConfiguration>();
            foreach (var type in typeSource)
            {
                if (typeof(IServerConfiguration).IsAssignableFrom(type) &&
                    !type.IsInterface && !type.IsAbstract)
                {
                    serverConfigurations.Add(Activator.CreateInstance(type) as IServerConfiguration);
                }
            }

            StartupTrace.WriteLine("Protected Startup: Found " + serverConfigurations.Count + " implementations of IServerConfiguration");

            if (gameConfigurations.Count == 0 && serverConfigurations.Count == 0)
            {
                throw new InvalidOperationException(
                          "You must have at least one implementation of " +
                          "IGameConfiguration or IServerConfiguration in your game.");
            }
#else
            if (gameConfigurations.Count == 0)
            {
                throw new InvalidOperationException(
                          "You must have at least one implementation of " +
                          "IGameConfiguration in your game.");
            }
#endif

            StartupTrace.TimingEntries["constructGameConfigurationImplementations"] = stopwatch.Elapsed;
            stopwatch.Restart();

            ICoreGame game = null;

#if CAN_RUN_DEDICATED_SERVER
            ICoreServer server = null;
#endif

            StartupTrace.WriteLine("Protected Startup: Starting iteration through game configuration implementations");

            foreach (var configuration in gameConfigurations)
            {
                StartupTrace.WriteLine("Protected Startup: Configuring kernel with " + configuration.GetType().FullName);
                configuration.ConfigureKernel(kernel);

                StartupTrace.TimingEntries["configureKernel(" + configuration.GetType().FullName + ")"] = stopwatch.Elapsed;
                stopwatch.Restart();

                // We only construct one game.  In the event there are
                // multiple game configurations (such as a third-party library
                // providing additional game tools, it's expected that libraries
                // will return null for ConstructGame).
                if (game == null)
                {
                    StartupTrace.WriteLine("Protected Startup: Attempted to construct game with " + configuration.GetType().FullName);
                    game = configuration.ConstructGame(kernel);
                    StartupTrace.WriteLineIf(game != null, "Protected Startup: Constructed game with " + configuration.GetType().FullName);

                    StartupTrace.TimingEntries["constructGame(" + configuration.GetType().FullName + ")"] = stopwatch.Elapsed;
                    stopwatch.Restart();
                }
            }

            StartupTrace.WriteLine("Protected Startup: Finished iteration through game configuration implementations");

#if CAN_RUN_DEDICATED_SERVER
            StartupTrace.WriteLine("Protected Startup: Starting iteration through server configuration implementations");

            foreach (var serverConfiguration in serverConfigurations)
            {
                StartupTrace.WriteLine("Protected Startup: Configuring kernel with " + serverConfiguration.GetType().FullName);
                serverConfiguration.ConfigureKernel(kernel);

                // We only construct one server.  In the event there are
                // multiple server configurations (such as a third-party library
                // providing additional game tools, it's expected that libraries
                // will return null for ConstructServer).
                if (server == null)
                {
                    StartupTrace.WriteLine("Protected Startup: Attempted to construct server with " + serverConfiguration.GetType().FullName);
                    server = serverConfiguration.ConstructServer(kernel);
                    Debug.WriteLineIf(server != null, "Protected Startup: Constructed server with " + serverConfiguration.GetType().FullName);
                }
            }

            StartupTrace.WriteLine("Protected Startup: Finished iteration through server configuration implementations");

            if (game == null && server == null)
            {
                throw new InvalidOperationException(
                          "No implementation of IGameConfiguration provided " +
                          "a game instance from ConstructGame, and " +
                          "no implementation of IServerConfiguration provided " +
                          "a server instance from ConstructServer.");
            }

            if (game != null && server != null)
            {
                throw new InvalidOperationException(
                          "An implementation of IGameConfiguration provided " +
                          "a game instance, and an implementation of " +
                          "IServerConfiguration provided a server instance.  " +
                          "It's not possible to determine whether the game or " +
                          "server should be started with this configuration.  " +
                          "Move one of the implementations so that it's not in " +
                          "the default loaded application domain.");
            }
#else
            if (game == null)
            {
                throw new InvalidOperationException(
                          "No implementation of IGameConfiguration provided " +
                          "a game instance from ConstructGame.");
            }
#endif

            StartupTrace.TimingEntries["finalizeStartup"] = stopwatch.Elapsed;
            stopwatch.Stop();

            return(new StartupSequenceResult
            {
                Kernel = kernel,
                GameInstance = game,
#if CAN_RUN_DEDICATED_SERVER
                ServerInstance = server,
#endif
            });
        }
 /// <summary>
 /// Creates a new <see cref="AuthenticationHandler"/> instance.
 /// </summary>
 /// <param name="logger">Logger.</param>
 /// <param name="coreServer">Core server instance.</param>
 /// <param name="corePacketFactory">Core server packet factory.</param>
 public AuthenticationHandler(ILogger <AuthenticationHandler> logger, ICoreServer coreServer, ICorePacketFactory corePacketFactory)
 {
     _logger            = logger;
     _coreServer        = coreServer;
     _corePacketFactory = corePacketFactory;
 }
 public UpdateController(AutomaticaContext dbContext, ICloudApi api, ICoreServer coreServer) : base(dbContext)
 {
     this.api   = api;
     CoreServer = coreServer;
 }
Exemple #14
0
 public NodeInstanceController(AutomaticaContext db, INotifyDriver notifyDriver, ICoreServer coreServer)
     : base(db)
 {
     _notifyDriver = notifyDriver;
     _coreServer   = coreServer;
 }
Exemple #15
0
 /// <summary>
 /// Creates a new <see cref="CoreServerService"/> instance.
 /// </summary>
 /// <param name="logger">Logger.</param>
 /// <param name="coreServer">Core server.</param>
 public CoreServerService(ILogger <CoreServerService> logger, ICoreServer coreServer)
 {
     _logger     = logger;
     _coreServer = coreServer;
 }
Exemple #16
0
    private static void ProtectedStartup(string[] args)
    {
#endif
        var kernel = new StandardKernel();
        kernel.Bind <IRawLaunchArguments>().ToMethod(x => new DefaultRawLaunchArguments(args)).InSingletonScope();

        Func <System.Reflection.Assembly, Type[]> TryGetTypes = assembly =>
        {
            try
            {
                return(assembly.GetTypes());
            }
            catch
            {
                return(new Type[0]);
            }
        };

        // Search the application domain for implementations of
        // the IGameConfiguration.
        var gameConfigurations =
            (from assembly in AppDomain.CurrentDomain.GetAssemblies()
             from type in TryGetTypes(assembly)
             where typeof(IGameConfiguration).IsAssignableFrom(type) &&
             !type.IsInterface && !type.IsAbstract
             select Activator.CreateInstance(type) as IGameConfiguration).ToList();

#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX
        // Search the application domain for implementations of
        // the IServerConfiguration.
        var serverConfigurations =
            (from assembly in AppDomain.CurrentDomain.GetAssemblies()
             from type in TryGetTypes(assembly)
             where typeof(IServerConfiguration).IsAssignableFrom(type) &&
             !type.IsInterface && !type.IsAbstract
             select Activator.CreateInstance(type) as IServerConfiguration).ToList();

        if (gameConfigurations.Count == 0 && serverConfigurations.Count == 0)
        {
            throw new InvalidOperationException(
                      "You must have at least one implementation of " +
                      "IGameConfiguration or IServerConfiguration in your game.");
        }
#else
        if (gameConfigurations.Count == 0)
        {
            throw new InvalidOperationException(
                      "You must have at least one implementation of " +
                      "IGameConfiguration in your game.");
        }
#endif

        Game game = null;
#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX
        ICoreServer server = null;
#endif

        foreach (var gameConfiguration in gameConfigurations)
        {
            gameConfiguration.ConfigureKernel(kernel);

            // It is expected that the AssetManagerProvider architecture will
            // be refactored in future to just provide IAssetManager directly,
            // and this method call will be dropped.
            gameConfiguration.InitializeAssetManagerProvider(new AssetManagerProviderInitializer(kernel, args));

            // We only construct one game.  In the event there are
            // multiple game configurations (such as a third-party library
            // providing additional game tools, it's expected that libraries
            // will return null for ConstructGame).
            if (game == null)
            {
                game = gameConfiguration.ConstructGame(kernel);
            }
        }

#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX
        foreach (var serverConfiguration in serverConfigurations)
        {
            serverConfiguration.ConfigureKernel(kernel);

            // It is expected that the AssetManagerProvider architecture will
            // be refactored in future to just provide IAssetManager directly,
            // and this method call will be dropped.
            serverConfiguration.InitializeAssetManagerProvider(new AssetManagerProviderInitializer(kernel, args));

            // We only construct one server.  In the event there are
            // multiple server configurations (such as a third-party library
            // providing additional game tools, it's expected that libraries
            // will return null for ConstructServer).
            if (server == null)
            {
                server = serverConfiguration.ConstructServer(kernel);
            }
        }

        _kernel = kernel;
        _game   = game;
        _server = server;
    }
Exemple #17
0
 /// <summary>
 /// Creates a new <see cref="CommonCoreHandler"/> instance.
 /// </summary>
 /// <param name="logger">Logger.</param>
 /// <param name="coreServer">Core server.</param>
 /// <param name="corePacketFactory">Core packet factory.</param>
 public CommonCoreHandler(ILogger <CommonCoreHandler> logger, ICoreServer coreServer, ICorePacketFactory corePacketFactory)
 {
     _logger            = logger;
     _coreServer        = coreServer;
     _corePacketFactory = corePacketFactory;
 }
Exemple #18
0
    private static void ProtectedStartup(string[] args)
    {
		Debug.WriteLine("Protected Startup: Execution of protected startup has begun");

        var kernel = new StandardKernel();
        kernel.Bind<IRawLaunchArguments>().ToMethod(x => new DefaultRawLaunchArguments(args)).InSingletonScope();
        
		Func<System.Reflection.Assembly, Type[]> TryGetTypes = assembly =>
		{
			try
			{
				return assembly.GetTypes();
			}
			catch
			{
				return new Type[0];
			}
		};

		Debug.WriteLine("Protected Startup: Scanning for implementations of IGameConfiguration");

        // Search the application domain for implementations of
        // the IGameConfiguration.
        var gameConfigurations =
            (from assembly in AppDomain.CurrentDomain.GetAssemblies()
				from type in TryGetTypes(assembly)
            where typeof (IGameConfiguration).IsAssignableFrom(type) &&
                  !type.IsInterface && !type.IsAbstract
            select Activator.CreateInstance(type) as IGameConfiguration).ToList();

		Debug.WriteLine("Protected Startup: Found " + gameConfigurations.Count + " implementations of IGameConfiguration");

#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX

		Debug.WriteLine("Protected Startup: Scanning for implementations of IServerConfiguration");

        // Search the application domain for implementations of
        // the IServerConfiguration.
        var serverConfigurations =
            (from assembly in AppDomain.CurrentDomain.GetAssemblies()
             from type in TryGetTypes(assembly)
             where typeof(IServerConfiguration).IsAssignableFrom(type) &&
               !type.IsInterface && !type.IsAbstract
             select Activator.CreateInstance(type) as IServerConfiguration).ToList();

		Debug.WriteLine("Protected Startup: Found " + serverConfigurations.Count + " implementations of IServerConfiguration");

        if (gameConfigurations.Count == 0 && serverConfigurations.Count == 0)
        {
            throw new InvalidOperationException(
                "You must have at least one implementation of " +
                "IGameConfiguration or IServerConfiguration in your game.");
        }
#else
        if (gameConfigurations.Count == 0)
        {
            throw new InvalidOperationException(
                "You must have at least one implementation of " +
                "IGameConfiguration in your game.");
        }
#endif

        Game game = null;
#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX
        ICoreServer server = null;
#endif

		Debug.WriteLine("Protected Startup: Starting iteration through game configuration implementations");

        foreach (var gameConfiguration in gameConfigurations)
        {
			Debug.WriteLine("Protected Startup: Configuring kernel with " + gameConfiguration.GetType().FullName);
            gameConfiguration.ConfigureKernel(kernel);

            // It is expected that the AssetManagerProvider architecture will
            // be refactored in future to just provide IAssetManager directly,
			// and this method call will be dropped.
			Debug.WriteLine("Protected Startup: Initializing asset manager provider with " + gameConfiguration.GetType().FullName);
            gameConfiguration.InitializeAssetManagerProvider(new AssetManagerProviderInitializer(kernel, args));

            // We only construct one game.  In the event there are
            // multiple game configurations (such as a third-party library
            // providing additional game tools, it's expected that libraries
            // will return null for ConstructGame).
            if (game == null)
			{
				Debug.WriteLine("Protected Startup: Attempted to construct game with " + gameConfiguration.GetType().FullName);
                game = gameConfiguration.ConstructGame(kernel);
				Debug.WriteLineIf(game != null, "Protected Startup: Constructed game with " + gameConfiguration.GetType().FullName);
            }
        }

		Debug.WriteLine("Protected Startup: Finished iteration through game configuration implementations");

#if PLATFORM_WINDOWS || PLATFORM_MACOS || PLATFORM_LINUX

		Debug.WriteLine("Protected Startup: Starting iteration through server configuration implementations");

        foreach (var serverConfiguration in serverConfigurations)
        {
			Debug.WriteLine("Protected Startup: Configuring kernel with " + serverConfiguration.GetType().FullName);
			serverConfiguration.ConfigureKernel(kernel);

            // It is expected that the AssetManagerProvider architecture will
            // be refactored in future to just provide IAssetManager directly,
            // and this method call will be dropped.
			Debug.WriteLine("Protected Startup: Initializing asset manager provider with " + serverConfiguration.GetType().FullName);
			serverConfiguration.InitializeAssetManagerProvider(new AssetManagerProviderInitializer(kernel, args));

            // We only construct one server.  In the event there are
            // multiple server configurations (such as a third-party library
            // providing additional game tools, it's expected that libraries
            // will return null for ConstructServer).
            if (server == null)
            {
				Debug.WriteLine("Protected Startup: Attempted to construct server with " + serverConfiguration.GetType().FullName);
				server = serverConfiguration.ConstructServer(kernel);
				Debug.WriteLineIf(server != null, "Protected Startup: Constructed server with " + serverConfiguration.GetType().FullName);
            }
        }

		Debug.WriteLine("Protected Startup: Finished iteration through server configuration implementations");

        _kernel = kernel;
        _game = game;
        _server = server;
    }