/// <summary>
 /// Initializes a new instance of the SchedulerAdapterClientFactory class
 /// </summary>
 /// <param name="sharedData">indicating the shared data</param>
 /// <param name="monitor">indicating the monitor</param>
 /// <param name="dispatcherManager">indicating the dispatcher manager</param>
 public SchedulerAdapterClientFactory(SharedData sharedData, ServiceJobMonitorBase monitor, DispatcherManager dispatcherManager, ITelepathyContext context)
 {
     this.sharedData        = sharedData;
     this.monitor           = monitor;
     this.dispatcherManager = dispatcherManager;
     this.context           = context;
 }
Example #2
0
        /// <summary>
        /// Build initialization result
        /// </summary>
        /// <param name="frontendResult">indicating the frontend result</param>
        /// <param name="dispatcherManager">indicating the dispatcher manager</param>
        /// <param name="serviceOperationTimeout">indicating service operation timeout</param>
        /// <param name="clientBrokerHeartbeatInterval">indicating client broker heartbeat interval</param>
        /// <param name="clientBrokerHeartbeatRetryCount">indicating client broker heartbeat retry count</param>
        /// <param name="azureRequestQueueUris">the Azure storage queue SAS Uri</param>
        /// <param name="azureRequestBlobUri">the Azure storage blob container SAS Uri</param>
        /// <param name="useAzureQueue">if the azure storage queue(blob) is used</param>
        /// <returns>returns the initialization result</returns>
        private static BrokerInitializationResult BuildInitializationResult(
            FrontendResult frontendResult,
            DispatcherManager dispatcherManager,
            int serviceOperationTimeout,
            int clientBrokerHeartbeatInterval,
            int clientBrokerHeartbeatRetryCount,
            string[] azureRequestQueueUris,
            string azureRequestBlobUri,
            bool?useAzureQueue)
        {
            BrokerInitializationResult info = new BrokerInitializationResult();

            info.BrokerEpr                       = frontendResult.FrontendUriList;
            info.ControllerEpr                   = frontendResult.ControllerUriList;
            info.ResponseEpr                     = frontendResult.GetResponseUriList;
            info.ServiceOperationTimeout         = serviceOperationTimeout;
            info.ClientBrokerHeartbeatInterval   = clientBrokerHeartbeatInterval;
            info.ClientBrokerHeartbeatRetryCount = clientBrokerHeartbeatRetryCount;
            info.MaxMessageSize                  = frontendResult.MaxMessageSize;
            info.SupportsMessageDetails          = frontendResult.FrontendSupportsMessageDetails && dispatcherManager.BackendSupportsMessageDetails;
            info.AzureRequestQueueUris           = azureRequestQueueUris;
            info.AzureRequestBlobUri             = azureRequestBlobUri;
            info.UseAzureQueue                   = (useAzureQueue == true);
            return(info);
        }
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Example #4
0
        private static BrokerInitializationResult BuildInitializationResult(
            FrontendResult frontendResult,
            DispatcherManager dispatcherManager,
            int serviceOperationTimeout,
            int clientBrokerHeartbeatInterval,
            int clientBrokerHeartbeatRetryCount,
            string[] azureRequestQueueUris,
            string azureRequestBlobUri,
            string controllerRequestQueueUri,
            string controllerResponseQueueUri,
            bool?useAzureQueue
            )
        {
            var info = BuildInitializationResult(
                frontendResult,
                dispatcherManager,
                serviceOperationTimeout,
                clientBrokerHeartbeatInterval,
                clientBrokerHeartbeatRetryCount,
                azureRequestQueueUris,
                azureRequestBlobUri,
                useAzureQueue);

            info.AzureControllerRequestQueueUri  = controllerRequestQueueUri;
            info.AzureControllerResponseQueueUri = controllerResponseQueueUri;
            return(info);
        }
Example #5
0
 public void createCitizen()
 {
     for (int i = 0; i < 2; i++)
     {
         citizen = Instantiate(citizen, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z), Quaternion.identity) as GameObject;
         citizen.SetActive(true);
         DispatcherManager dm = GameObject.Find("Dispatcher").GetComponent <DispatcherManager>();
         dm.noneCitizens.Add(citizen.GetComponent <Citizen>());
         dm.updateCitizenList(citizen.GetComponent <Citizen>());
     }
 }
Example #6
0
 /// <summary>
 /// 1 quartZ引入&初始化&使用
 /// 2 核心对象Job、Trigger解析
 /// 3 三种Listener扩展订制
 /// 4 可视化界面管理&WindowsService承载
 /// 5 IOC容器结合
 /// 6 自定义的定时调度框架
 ///
 /// </summary>
 /// <param name="args"></param>
 static void Main(string[] args)
 {
     try
     {
         Console.WriteLine("欢迎来到.Net高级班VIP课程,Richard老师讲解定时调度服务");
         //CustomSchedulingTask.TaskStart();
         DispatcherManager.Init().GetAwaiter().GetResult();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     Console.Read();
 }
Example #7
0
            public DispatcherMessageQueueThread(string name, Action <Exception> handler, bool isSecondary)
                : base(name)
            {
                _isSecondary    = isSecondary;
                _actionSubject  = new Subject <Action>();
                _actionObserver = _actionSubject;

#if WINDOWS_UWP
#if CREATE_LAYOUT_THREAD
                _currentApplicationView = isSecondary
                    ? s_layoutApplicationView
                    : CoreApplication.GetCurrentView();
#else
                // For DEBUG builds, we use the main UI dispatcher fors both
                // layout and dispatcher queue threads because of a limitation
                // with the native debugging capabilities.
                _currentApplicationView = CoreApplication.GetCurrentView();
#endif
                var dispatcher = _currentApplicationView.Dispatcher;
#else
                if (_isSecondary)
                {
                    _layoutDispatcherManager = new DispatcherManager();
                }

                var dispatcher = isSecondary
                    ? _layoutDispatcherManager.DispatcherInstance
                    : Dispatcher.CurrentDispatcher;

                _currentDispatcherThread = dispatcher.Thread;
#endif

                _subscription = _actionSubject
                                .ObserveOn(dispatcher)
                                .Subscribe(action =>
                {
                    try
                    {
                        action();
                    }
                    catch (Exception ex)
                    {
                        handler(ex);
                    }
                });
            }
        public void NewDispatcherTest()
        {
            int             jobId       = 1;
            int             taskId      = 1;
            int             niceId      = 1;
            string          machineName = Environment.MachineName;
            EndpointAddress epr         = this.GetEndpointAddress(jobId, taskId, machineName);
            MockBrokerQueue queue       = new MockBrokerQueue();

            ServiceHost host = StartMockServiceHost(epr);

            Global.SetBrokerQueue(new MockBrokerQueue());
            DispatcherManager manager = new DispatcherManager(1, String.Empty);

            manager.NewDispatcher(jobId, taskId, niceId, machineName);

            Message request = Message.CreateMessage(MessageVersion.Default, "NewDispatcherTest", "Test");

            request.Headers.MessageId = new UniqueId();
            queue.TriggerGetRequestCallback(new BrokerQueueItem(new DummyRequestContext(MessageVersion.Default), request, null));

            Thread.Sleep(500);
            int tryCount = 0;

            while (tryCount < 3)
            {
                if (queue.ReplyMessageQueue.Count > 0)
                {
                    Message reply        = queue.ReplyMessageQueue.Dequeue();
                    string  replyMessage = reply.GetBody <string>();
                    Assert.AreEqual("TestReply", replyMessage);
                    break;
                }

                Thread.Sleep(3000);
                tryCount++;
            }

            if (tryCount >= 3)
            {
                Assert.Fail("Timeout");
            }

            host.Close();
        }
Example #9
0
        /// <summary>
        /// Override Start method and start dummy service job monitor
        /// </summary>
        /// <param name="startInfo"></param>
        /// <param name="dispatcherManager"></param>
        /// <param name="observer"></param>
        /// <returns></returns>
        public override async Task Start(SessionStartInfoContract startInfo, DispatcherManager dispatcherManager, BrokerObserver observer)
        {
            BrokerTracing.TraceVerbose("[ServiceJobMonitor].Start: Enter");

            this.dispatcherManager = dispatcherManager;
            this.observer          = observer;

            this.gracefulPreemptionHandler = new GracefulPreemptionHandler(this.dispatcherManager, this.sharedData.BrokerInfo.SessionId, taskId => this.FinishTask(taskId, isRunAwayTask: true));

            this.schedulerAdapterClientFactory = new SchedulerAdapterClientFactory(this.sharedData, this, dispatcherManager, this.context);

            if (this.sharedData.Config.Monitor.AllocationAdjustInterval != Timeout.Infinite && this.sharedData.StartInfo.EprList == null)
            {
                BrokerTracing.TraceVerbose("[ServiceJobMonitor].Start: start the allocation adjust thread, interval={0}", this.sharedData.Config.Monitor.AllocationAdjustInterval);

                this.allocationAdjustThread.Start();
            }

            // await SvcHostRestModule.OpenSvcHostsAsync(this.sharedData.BrokerInfo.SessionId, startInfo, ((ISchedulerNotify)this).TaskStateChanged);

            await((ISchedulerNotify)this).TaskStateChanged(SvcHostRestModule.CreateDummyTaskInfos(startInfo.IpAddress));
        }
        protected override IAsyncResult OnBeginSend(Message message, TimeSpan timeout, AsyncCallback callback, object state)
        {
            Uri to = EnsureAnonymous(message);

            return(new SendAsyncResult(DispatcherManager.Get(to), message, timeout, callback, state));
        }
Example #11
0
        /// <summary>
        /// Start the service job monitor
        /// </summary>
        /// <param name="dispatcherManager">indicating dispatcher manager</param>
        /// <param name="observer">indicating the observer</param>
        public async Task Start(DispatcherManager dispatcherManager, BrokerObserver observer)
        {
            BrokerTracing.TraceVerbose("[ServiceJobMonitor].Start: Enter");

            this.dispatcherManager = dispatcherManager;
            this.observer          = observer;

            this.gracefulPreemptionHandler = new GracefulPreemptionHandler(
                this.dispatcherManager,
                this.sharedData.BrokerInfo.SessionId,
                taskId => this.FinishTask(taskId, isRunAwayTask: true));

            this.schedulerAdapterClientFactory = new SchedulerAdapterClientFactory(this.sharedData, this, dispatcherManager, this.context);

            try
            {
                // Bug 14035: Need to call GetSchedulerAdapterClient() to invoke RegisterJob() operation
                await this.schedulerAdapterClientFactory.GetSchedulerAdapterClientAsync();
            }
            catch (Exception e)
            {
                BrokerTracing.TraceVerbose("[ServiceJobMonitor].Start: Exception: {0}", e.ToString());
                throw;
            }

            this.trigger = new RepeatableCallbackTrigger();
            WaitCallback updateStatusWaitCallback           = new ThreadHelper <object>(new WaitCallback(this.UpdateStatus)).CallbackRoot;
            WaitCallback loadSampleWaitCallback             = new ThreadHelper <object>(new WaitCallback(this.LoadSample)).CallbackRoot;
            WaitCallback schedulerDelegationTimeoutCallback = new ThreadHelper <object>(new WaitCallback(this.SchedulerDelegationTimeout)).CallbackRoot;
            WaitCallback finishTaskCallback = new ThreadHelper <object>(new WaitCallback(this.FinishTasksThread)).CallbackRoot;

            BrokerTracing.TraceVerbose(
                "[ServiceJobMonitor].Start: Register updateStatusWaitCallback, interval={0}",
                this.sharedData.Config.Monitor.StatusUpdateInterval);
            this.trigger.RegisterCallback(TimeSpan.FromMilliseconds(this.sharedData.Config.Monitor.StatusUpdateInterval), TimeSpan.FromSeconds(FirstUpdateStatusSeconds), updateStatusWaitCallback, "TIMERCALLBACK");

            BrokerTracing.TraceVerbose(
                "[ServiceJobMonitor].Start: Register loadSampleWaitCallback, interval={0}",
                this.sharedData.Config.Monitor.LoadSamplingInterval);
            this.trigger.RegisterCallback(TimeSpan.FromMilliseconds(this.sharedData.Config.Monitor.LoadSamplingInterval), loadSampleWaitCallback, null);

            this.trigger.RegisterCallback(TimeSpan.FromMilliseconds(FinishTasksInterval), TimeSpan.FromMilliseconds(FinishTasksInterval), finishTaskCallback, null);

            // Get value of automaticShrinkEnabled cluster param
            this.automaticShrinkEnabled = this.sharedData.BrokerInfo.AutomaticShrinkEnabled;

            // If the allocationAdjustInterval setting is not infinite, start timer to adjust the allocation as appropriate
            // Bug 10492: Disable grow/shrink in debug mode
            if (this.sharedData.Config.Monitor.AllocationAdjustInterval != Timeout.Infinite && this.sharedData.StartInfo.EprList == null)
            {
                BrokerTracing.TraceVerbose(
                    "[ServiceJobMonitor].Start: start the allocation adjust thread, interval={0}",
                    this.sharedData.Config.Monitor.AllocationAdjustInterval);

                this.allocationAdjustThread.Start();
            }

            this.trigger.Start();

            this.schedulerNotifyTimeoutManager.RegisterTimeout(TimeoutPeriodFromSchedulerDelegationEvent, schedulerDelegationTimeoutCallback, null);

            if (this.sharedData.StartInfo.IsNoSession)
            {
                await this.OpenPreDefinedServiceHosts();
            }

            BrokerTracing.TraceVerbose("[ServiceJobMonitor].Start: Exit");
        }
Example #12
0
 /// <summary>
 /// override the Start Method in internal service job monitor
 /// </summary>
 /// <param name="startInfo"></param>
 /// <param name="dispatcherManager"></param>
 /// <param name="observer"></param>
 /// <returns></returns>
 public override async Task Start(SessionStartInfoContract startInfo, DispatcherManager dispatcherManager, BrokerObserver observer)
 {
     await this.Start(dispatcherManager, observer);
 }
 /// <summary>
 /// Initializes a new instance of the DummySchedulerAdapterClient class
 /// </summary>
 /// <param name="eprList">indicating the epr list</param>
 /// <param name="dispatcherManager">indicating the dispatcher manager instance</param>
 public DummySchedulerAdapterClient(string[] eprList, DispatcherManager dispatcherManager)
 {
     this.dispatcherManager = dispatcherManager;
     this.eprList           = eprList;
 }
Example #14
0
        /// <summary>
        /// Run the broker
        /// </summary>
        /// <param name="startInfo">session start info</param>
        /// <param name="brokerInfo">indicate the broker start info</param>
        /// <returns>initialization result</returns>
        public BrokerInitializationResult Run(SessionStartInfoContract startInfo, BrokerStartInfo brokerInfo)
        {
            BrokerTracing.TraceEvent(System.Diagnostics.TraceEventType.Information, 0, "[BrokerEntry] Broker is starting initialization, ID = {0}", brokerInfo.SessionId);

            try
            {
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: ClusterTopology is {0}", brokerInfo.NetworkTopology);

                // Step 1: Initialize configuration and shared data
                ServiceConfiguration serviceConfig;
                BrokerConfigurations brokerConfig;
                BindingsSection      bindings;
                SoaCommonConfig.WithoutSessionLayer = startInfo.IsNoSession; // TODO: this is a hack. Working mode should be decided by something like a *SchedulerType* filed.

                ConfigurationHelper.LoadConfiguration(startInfo, brokerInfo, out brokerConfig, out serviceConfig, out bindings);
                this.sharedData = new SharedData(brokerInfo, startInfo, brokerConfig, serviceConfig);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 1: Loading configuration and shared data succeeded.");
                Debug.WriteLine($"[BrokerEntry](Debug) UseAad:{startInfo.UseAad}");

                // Step 2: Initialize broker queue
                ClientInfo[] clientInfo;
                this.brokerQueueFactory = BrokerEntry.InitBrokerQueue(this.sharedData, out clientInfo);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 2: Initialize broker queue succeeded.");

                // Step 3: Initialize observer
                this.observer            = new BrokerObserver(this.sharedData, clientInfo);
                this.sharedData.Observer = this.observer;
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 3: Initialize broker observer succeeded.");

                // Step 4: Initialize state manager
                this.stateManager = new BrokerStateManager(this.sharedData, clientInfo.Length != 0);
                this.stateManager.UnloadBroker += this.UnloadBroker;
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 4: Initialize broker state manager succeeded.");

                // Step 5: Initialize service job monitor
                var context = TelepathyContext.GetOrAdd(this.sharedData.BrokerInfo.Headnode);

                if (SoaCommonConfig.WithoutSessionLayer)
                {
                    this.monitor = new DummyServiceJobMonitor(this.sharedData, this.stateManager, this.nodeMappingData, context);
                }
                else
                {
                    this.monitor = new ServiceJobMonitor.ServiceJobMonitor(this.sharedData, this.stateManager, this.nodeMappingData, context);
                }
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 5: Initialize service job monitor succeeded.");

                // Step 6: Initalize broker authorization
                this.brokerAuth = BrokerEntry.BuildBrokerAuthorization(this.sharedData);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 6: Initialize broker authorization succeeded.");

                // Step 7: Initialize dispatcher manager
                DispatcherManager dispatcherManager = new DispatcherManager(bindings, this.sharedData, this.observer, this.monitor, this.brokerQueueFactory, context);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 7: Initialize dispatcher manager succeeded.");

                // Step 8: Start service job monitor
                this.monitor.Start(startInfo, dispatcherManager, this.observer).GetAwaiter().GetResult();
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 8: Start service job monitor succeeded.");

                // Step 9: Initailize client manager
                this.clientManager = new BrokerClientManager(clientInfo, this.brokerQueueFactory, this.observer, this.stateManager, this.monitor, this.sharedData);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 9: Initialize client manager succeeded.");

                // if using AzureQueue, retrieve the connection string and build the request and response message queues if not exist
                string[] requestQueueUris           = { };
                string   requestBlobUri             = string.Empty;
                string   controllerRequestQueueUri  = string.Empty;
                string   controllerResponseQueueUri = string.Empty;
                if (startInfo.UseAzureStorage)
                {
                    int clusterHash = 0;
                    if (!string.IsNullOrEmpty(brokerInfo.ClusterId))
                    {
                        string clusterIdString = brokerInfo.ClusterId.ToLowerInvariant();
                        clusterHash = clusterIdString.GetHashCode();
                    }
                    else if (!string.IsNullOrEmpty(brokerInfo.ClusterName))
                    {
                        string clusterNameString = brokerInfo.ClusterName.ToLowerInvariant();
                        clusterHash = clusterNameString.GetHashCode();
                    }
                    else
                    {
                        throw new InvalidOperationException($"Both {nameof(brokerInfo.ClusterId)} and {nameof(brokerInfo.ClusterName)} are null or empty. No {nameof(clusterHash)} can be determined.");
                    }

                    if (!string.IsNullOrEmpty(brokerInfo.AzureStorageConnectionString))
                    {
                        this.azureQueueProxy = new AzureQueueProxy(brokerInfo.ClusterName, clusterHash, this.SessionId, brokerInfo.AzureStorageConnectionString);
                        requestQueueUris     = this.azureQueueProxy.RequestQueueUris;
                        requestBlobUri       = this.azureQueueProxy.RequestBlobUri;
                        var requestQName  = CloudQueueConstants.GetBrokerWorkerControllerRequestQueueName(this.SessionId);
                        var responseQName = CloudQueueConstants.GetBrokerWorkerControllerResponseQueueName(this.SessionId);
                        controllerRequestQueueUri = CloudQueueCreationModule.CreateCloudQueueAndGetSas(
                            brokerInfo.AzureStorageConnectionString,
                            requestQName,
                            CloudQueueCreationModule.AddMessageSasPolicy).GetAwaiter().GetResult();
                        controllerResponseQueueUri = CloudQueueCreationModule.CreateCloudQueueAndGetSas(
                            brokerInfo.AzureStorageConnectionString,
                            responseQName,
                            CloudQueueCreationModule.ProcessMessageSasPolicy).GetAwaiter().GetResult();
                        if (this.SessionId == SessionStartInfo.StandaloneSessionId)
                        {
                            CloudQueueCreationModule.ClearCloudQueuesAsync(brokerInfo.AzureStorageConnectionString, new[] { requestQName, responseQName });
                        }
                    }
                    else
                    {
                        BrokerTracing.TraceError("[BrokerEntry] Initialization: Use Azure Queue is specified, however the Azure connection string is not set.");
                        ThrowHelper.ThrowSessionFault(SOAFaultCode.Broker_AzureConnectionStringNotAvailable, SR.Broker_AzureConnectionStringNotAvailable);
                    }
                }

                // Step 10: Initialize frontend
                this.frontendResult = FrontEndBuilder.BuildFrontEnd(this.sharedData, this.observer, this.clientManager, this.brokerAuth, bindings, this.azureQueueProxy);
                ////this.maxMessageSize = (int)this.frontendResult.MaxMessageSize;
                ////this.readerQuotas = this.frontendResult.ReaderQuotas;
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 10: Initialize frontend succeeded.");

                // Step 11: Start frontend, Initialization finished after this step
                this.OpenFrontend();
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 11: Open frontend succeeded.");

                // Step 12: Build initialization result and retrun to client
                BrokerInitializationResult result = BrokerEntry.BuildInitializationResult(
                    this.frontendResult,
                    dispatcherManager,
                    this.sharedData.Config.LoadBalancing.ServiceOperationTimeout,
                    this.sharedData.Config.Monitor.ClientBrokerHeartbeatInterval,
                    this.sharedData.Config.Monitor.ClientBrokerHeartbeatRetryCount,
                    requestQueueUris,
                    requestBlobUri,
                    controllerRequestQueueUri,
                    controllerResponseQueueUri,
                    startInfo.UseAzureStorage);
                BrokerTracing.TraceVerbose("[BrokerEntry] Initialization: Step 12: Build initialization result suceeded.");
                BrokerTracing.TraceInfo("[BrokerEntry] Initialization succeeded.");
                return(result);
            }
            catch (Exception ex)
            {
                BrokerTracing.TraceError(ex.ToString());
                throw;
            }
            finally
            {
                if (this.sharedData != null)
                {
                    this.sharedData.InitializationFinished();
                }
            }
        }
Example #15
0
        internal static void Main()
        {
            NativeMethods.SetConsoleCtrlHandler(ConsoleCtrlOperationHandler, true);

            Game.Initialize();
            Tools.Initialize();
            OutputMessagePool.Initialize();
            NetworkMessagePool.Initialize();

            Console.Title = Constants.ServerName;
            Console.Clear();
            Console.WriteLine("Welcome to {0} - Version {1}", Constants.ServerName, Constants.ServerVersion);
            Console.WriteLine("Developed by {0}", Constants.ServerDevelopers);
            Console.WriteLine();

            // Start Threads
            DispatcherManager.Start();

            // Loading config.lua
            if (!ConfigManager.Load("config.lua"))
            {
                ExitApplication();
            }

            if (!Enum.TryParse(ConfigManager.Instance[ConfigStr.MinConsoleLogLevel], true, out Logger.MinConsoleLogLevel))
            {
                Console.WriteLine("LOGGER LOG LEVEL COULD NOT BE PARSED! PLEASE FIX!");
                ExitApplication();
            }

            // Setting up process priority
            switch (ConfigManager.Instance[ConfigStr.DefaultPriority])
            {
            case "realtime":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
                break;

            case "high":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High;
                break;

            case "higher":
                Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;
                break;
            }

            // Setting up RSA cyrpto
            if (!Rsa.SetKey(RsaP, RsaQ))
            {
                ExitApplication();
            }

            // Initializing Database connection
            if (!Database.Initialize())
            {
                ExitApplication();
            }
            //DATABASE MANAGER UPDATE DATABASE
            //DATABASE TASKS START

            // Loading vocations
            if (!Vocation.LoadVocations())
            {
                ExitApplication();
            }

            // Loading items
            if (!ItemManager.Load())
            {
                ExitApplication();
            }

            // Loading Chat Channels
            if (!Chat.Load())
            {
                ExitApplication();
            }

            // Loading scripts
            if (!ScriptManager.LoadCsScripts() || !ScriptManager.LoadLuaScripts())
            {
                ExitApplication();
            }

            // Loading Command Line Operations
            if (!ScriptManager.LoadCommandLineOperations())
            {
                ExitApplication();
            }

            // LOAD CREATURES HERE

            // Loading outfits
            if (!OutfitManager.Load())
            {
                ExitApplication();
            }

            // Loading map
            if (!Map.Load())
            {
                ExitApplication();
            }

            // Setting game world type
            switch (ConfigManager.Instance[ConfigStr.WorldType])
            {
            case "pvp":
                Game.WorldType = GameWorldTypes.Pvp;
                break;

            case "no-pvp":
                Game.WorldType = GameWorldTypes.NoPvp;
                break;

            case "pvp-enforced":
                Game.WorldType = GameWorldTypes.PvpEnforced;
                break;

            default:
                Logger.Log(LogLevels.Error, "Invalid game world type: " + ConfigManager.Instance[ConfigStr.WorldType]);
                ExitApplication();
                break;
            }
            Logger.Log(LogLevels.Operation, "Setting Game World Type: " + Game.WorldType);

            // Initialize Game State
            Game.GameState = GameStates.Init;

            //TODO: HOUSE RENTS
            //TODO: MARKET CHECK OFFERS
            //TODO: MARKET STATISTICS

            if (ConfigManager.Instance[ConfigBool.UseExternalLoginServer])
            {
                //Create secret communication channel with login server if login server is external
                if (!SecretServerConnection.Initialize())
                {
                    ExitApplication();
                }

                // Create signal waiting system to get authentication response from external login server
            }
            else
            {
                _loginServer = new LoginServer.LoginServer();
                _loginServer.Start();
            }

            GameServer.Start();
            Game.GameState = GameStates.Normal;
            Game.StartJobs();
            //TODO: FIRE SERVER RUNNING EVENT

            while (true)
            {
                string input = Console.ReadLine();

                if (input == null)
                {
                    continue;
                }

                string[]      firstPass  = input.Split('"');
                List <string> secondPass = firstPass[0].Trim().Split(' ').ToList();

                if (firstPass.Length > 1)
                {
                    for (int i = 1; i < firstPass.Length; i++)
                    {
                        if (i % 2 == 1)
                        {
                            secondPass.Add(firstPass[i]);
                        }
                        else
                        {
                            secondPass.AddRange(firstPass[i].Trim().Split(' '));
                        }
                    }
                }
                string[] command = secondPass.ToArray();

                if (ScriptManager.CommandLineOperations.ContainsKey(command[0]))
                {
                    try
                    {
                        ScriptManager.CommandLineOperations[command[0]].Invoke(command);
                    }
                    catch (Exception)
                    {
                        Logger.Log(LogLevels.Warning, "Command '" + command[0] + "' could not be executed in this environment!");
                    }
                }
                else
                {
                    Logger.Log(LogLevels.Warning, "Command is unknown!");
                }
            }
            // ReSharper disable FunctionNeverReturns
        }
Example #16
0
 private LayoutActionQueue(Action <Exception> onError, DispatcherManager dispatcherManager)
     : base(onError, dispatcherManager.Instance)
 {
     _dispatcherManager = dispatcherManager;
 }
Example #17
0
 internal SchedulerAdapterClient(Binding binding, EndpointAddress address, string[] predefinedSvcHost, DispatcherManager dispatcherManager, InstanceContext instanceContext) : base(instanceContext, binding, address)
 {
     this.predefinedSvcHost = predefinedSvcHost;
     this.dispatcherManager = dispatcherManager;
 }
 public Service1()
 {
     InitializeComponent();
     DispatcherManager.Init().GetAwaiter().GetResult();
 }