Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewCommandHandler"/> class.
 /// </summary>
 /// <param name="viewController">The controller for views.</param>
 /// <param name="applicationSelection">The application selection mechanism.</param>
 /// <param name="pluginsHost">The plugins host.</param>
 public ViewCommandHandler(IViewController viewController, IApplicationSelection applicationSelection,
                           IPluginsHost pluginsHost)
 {
     this.viewController       = viewController;
     this.applicationSelection = applicationSelection;
     this.pluginsHost          = pluginsHost;
 }
Exemplo n.º 2
0
        internal void LoadPlugins(IPluginsHost host, string pluginsDir)
        {
            _Host = host;

            var dir     = new DirectoryInfo(pluginsDir);
            var plugins = new PluginsComposition(dir.GetDirectories().Select(d => d.FullName));

            foreach (var type in plugins.Factory.GetPlugins().Select(p => p.GetType()))
            {
                if (type.GetInterface("PluginsCore.ISyncPlugin") != null)
                {
                    SyncPlugins.Add((ISyncPlugin)Activator.CreateInstance(type));
                }
                else if (type.GetInterface("PluginsCore.IPostPlugin") != null)
                {
                    SocialPlugins.Add((IPostPlugin)Activator.CreateInstance(type));
                }
            }

            //var dirs = new DirectoryInfo(pluginsDir).GetDirectories();
            //foreach (
            //    var type in
            //        dirs.Select(d => d.GetFiles(d.Name + ".dll"))
            //            .SelectMany(
            //                files =>
            //                files.Select(f => Assembly.Load(AssemblyName.GetAssemblyName(f.FullName)))
            //                     .Select(
            //                         ass =>
            //                         ass.GetTypes().FirstOrDefault(t => t.GetInterface("PluginsCore.IPlugin") != null))
            //                     .Where(type => type != null)))
            //{
            //    if (type.GetInterface("PluginsCore.ISyncPlugin") != null)
            //        SyncPlugins.Add((ISyncPlugin)Activator.CreateInstance(type));
            //    else if (type.GetInterface("PluginsCore.IPostPlugin") != null)
            //        PostPlugins.Add((IPostPlugin)Activator.CreateInstance(type));
            //}
            foreach (var p in SyncPlugins)
            {
                p.Init(host);
                p.BeforeSync   += sync_BeforeSync;
                p.SyncComplete += sync_SyncComplete;
            }
            foreach (var p in SocialPlugins)
            {
                p.Init(host);
                p.PostPerformed   += plugin_PostPerformed;
                p.GotPostsPartial += plugin_GotPostsPartial;
                p.GotPostsFull    += plugin_GotPostsFull;
            }
        }
Exemplo n.º 3
0
        internal void LoadPlugins(IPluginsHost host, string pluginsDir)
        {
            _Host = host;

            var dir = new DirectoryInfo(pluginsDir);
            var plugins = new PluginsComposition(dir.GetDirectories().Select(d => d.FullName));

            foreach (var type in plugins.Factory.GetPlugins().Select(p => p.GetType()))
            {
                if (type.GetInterface("PluginsCore.ISyncPlugin") != null)
                    SyncPlugins.Add((ISyncPlugin)Activator.CreateInstance(type));
                else if (type.GetInterface("PluginsCore.IPostPlugin") != null)
                    SocialPlugins.Add((IPostPlugin)Activator.CreateInstance(type));
            }

            //var dirs = new DirectoryInfo(pluginsDir).GetDirectories();
            //foreach (
            //    var type in
            //        dirs.Select(d => d.GetFiles(d.Name + ".dll"))
            //            .SelectMany(
            //                files =>
            //                files.Select(f => Assembly.Load(AssemblyName.GetAssemblyName(f.FullName)))
            //                     .Select(
            //                         ass =>
            //                         ass.GetTypes().FirstOrDefault(t => t.GetInterface("PluginsCore.IPlugin") != null))
            //                     .Where(type => type != null)))
            //{
            //    if (type.GetInterface("PluginsCore.ISyncPlugin") != null)
            //        SyncPlugins.Add((ISyncPlugin)Activator.CreateInstance(type));
            //    else if (type.GetInterface("PluginsCore.IPostPlugin") != null)
            //        PostPlugins.Add((IPostPlugin)Activator.CreateInstance(type));
            //}
            foreach (var p in SyncPlugins)
            {
                p.Init(host);
                p.BeforeSync += sync_BeforeSync;
                p.SyncComplete += sync_SyncComplete;
            }
            foreach (var p in SocialPlugins)
            {
                p.Init(host);
                p.PostPerformed += plugin_PostPerformed;
                p.GotPostsPartial += plugin_GotPostsPartial;
                p.GotPostsFull += plugin_GotPostsFull;
            }
        }
Exemplo n.º 4
0
        public bool Start()
        {
            _logger = LogManager.GetLogger("[MainHost]");

            _logger.Info("------------------------------JEDIUM SERVER---------------------------");
            _logger.Info("Starting at: " + DateTime.Now);

            //settings
            var     parser = new FileIniDataParser();
            IniData data   = parser.ReadFile("config\\ServerConfig.ini");

            MainSettings.BehavioursPluginPath = data["Server"]["BehavioursPluginPath"];
            MainSettings.WebApiHost           = data["Server"]["WebApiHost"];
            MainSettings.DBUrl                   = data["Server"]["DBUrl"];
            MainSettings.DatabaseName            = data["Server"]["DatabaseName"];
            MainSettings.CollectMessageStats     = bool.Parse(data["Statistics"]["CollectMessageStats"]);
            MainSettings.StatsCollectionInterval = int.Parse(data["Statistics"]["StatsCollectionInterval"]);
            MainSettings.mainURL                 = data["Server"]["MainURL"];
            MainSettings.TickDelay               = int.Parse(data["Server"]["TickDelay"]);

            _logger.Warn("___TICK DELAY:" + MainSettings.TickDelay);
            MD5 mcalc = MD5.Create();

            byte[] dbytes = File.ReadAllBytes("Domain.dll");
            MainSettings.ServerHash = mcalc.ComputeHash(dbytes).ToHex(false);
            _logger.Info($"Server domain hash: {MainSettings.ServerHash}");


            //preload domain
            var type = typeof(ISceneActor);

            if (type == null)
            {
                throw new InvalidProgramException("!");
            }

            //load plugins
            // BehaviourManager.LoadBehaviours(MainSettings.BehavioursPluginPath);


            //get config (app.config)
            AkkaConfigurationSection section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka");

            //_logger.Info();
            Config aconfig = section.AkkaConfig;

            Config localConfig = ConfigurationFactory.ParseString("akka.remote.helios.tcp.hostname = " + MainSettings.mainURL)
                                 .WithFallback(aconfig);

            //попытаться запустить актер сервера
            try
            {
                _system = ActorSystem.Create("VirtualFramework", localConfig);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                throw;
            }

            // на случай разрыва соединения
            DeadRequestProcessingActor.Install(_system);


            _databaseAgent = _system.ActorOf(Props.Create(() => new MongoDbActor()), "DataBase")
                             .Cast <DatabaseAgentRef>(); //TODO: Add test for connection

            _terminal = _system.ActorOf(Props.Create(() => new TerminalConnection(_databaseAgent)), "Terminal")
                        .Cast <TerminalConnectionRef>();


            _serverConnection = _system
                                .ActorOf(Props.Create(() => new ServerConnection(_databaseAgent)), "ServerEndpoint")
                                .Cast <ConnectionRef>();

            //_databaseAgent.SetDummyObjectTest().Wait();


            _manager = _system
                       .ActorOf(Props.Create(() => new ObjectsManager(_databaseAgent, _serverConnection)), "ObjectManager")
                       .Cast <ObjectsManagerRef>();


            //Editor

            _editorConnection = _system.ActorOf(Props.Create(() => new EditorConnection(_manager, _databaseAgent)), "EditorConnection")
                                .Cast <EditorConnectionRef>();

            //assets host
            _webApiHost = _system
                          .ActorOf(Props.Create(() => new WebApiHost(MainSettings.WebApiHost, _databaseAgent, _manager)),
                                   "AssetsHost")
                          .Cast <WebApiHostRef>();


            _pluginsHost = _system.ActorOf(Props.Create(() => new PluginsHost(_databaseAgent, _manager)), "PluginsHost")
                           .Cast <PluginsHostRef>();

            // _pluginsHost.LoadPlugins().Wait();


            _manager.LoadAllScenes().Wait();


            return(true);
        }