static void Main(string[] args)
        {
            LoggingExtensions.Logging.Log.InitializeWith <LoggingExtensions.log4net.Log4NetLog>();
            //Task t3 = new TaskFactory().StartNew(() =>
            //{
            //    using (var contrlSub = new NetMQ.Sockets.PullSocket("@" + ConfigurationManager.AppSettings["mon_controlInBindAddress"]))
            //    {
            //        while (true)
            //        {
            //            Console.WriteLine(contrlSub.ReceiveFrameString());
            //        }
            //    }

            //});

            Task t1 = new TaskFactory().StartNew(() =>
            {
                TaskBroker server = new TaskBroker();
                server.Initialize();
                server.Start();
            });

            Task t2 = new TaskFactory().StartNew(() =>
            {
                ControlBroker server = new ControlBroker();
                server.Initialize();
                server.Start();
            });


            t1.Wait();
            t2.Wait();
            //t3.Wait();
            //NetMQContext context = NetMQContext.Create();
            //NetMQSocket frontend = context.CreateRouterSocket();
            //NetMQSocket backend = context.CreateDealerSocket();
            //var frontAdress = ConfigurationManager.AppSettings["frontendBindAddress"];
            //var bakdendAdress = ConfigurationManager.AppSettings["backendBindAddress"];
            //frontend.Bind(frontAdress);
            //backend.Bind(bakdendAdress);
            ////frontend.ReceiveReady += frontend_ReceiveReady;
            ////backend.SendReady += backend_SendReady;
            //Proxy proxy = new Proxy(frontend, backend, null);
            //proxy.Start();

            //Poller _poller = new NetMQ.Poller();
            //QueueDevice _queue = new NetMQ.Devices.QueueDevice(context, _poller, frontAdress, bakdendAdress);
            //_queue.Start();
            //_poller.Start();
        }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        jetInventory = new List <GameObject>();
        ageInventory = new List <GameObject>();

        messageBrokerScript = messageBroker.GetComponent <MessageBroker>();
        jetBrokerScript     = assetBroker.GetComponent <JetBroker>();
        ageBrokerScript     = assetBroker.GetComponent <AgeBroker>();
        taskBrokerScript    = taskBroker.GetComponent <TaskBroker>();
        clockScript         = clock.GetComponent <Clock>();

        UpdateMoneyDisplay();
        TestInit();
    }
Exemple #3
0
        /// <summary>
        /// Execute the method specified in the task.
        /// If the task-object contains an object-host pair data, then the method
        /// will be executed on that object - otherwise, a brand new non-persistent
        /// object of the type specified in the task will be created and the method
        /// will be executed in that object.
        /// </summary>
        /// <param name="task">task</param>
        public void ExecuteTask(Task task)
        {
            try
            {
                // mark engine as busy for the taskbroker
                TaskBroker.UpdateEngineStatus(this.EngineId, EngineStatus.Busy);

                _task = task;
                object objectToProcess = null;
                bool   persistent      = false;

                // Check if the task contains a reference to a specific object
                if (task.ObjectData != null)
                {
                    if (_objectCollection.ContainsKey(task.ObjectData.ObjectId))
                    {
                        persistent      = true;
                        objectToProcess = _objectCollection[task.ObjectData.ObjectId];
                    }
                }
                // otherwise we instantiate a (non-persistent) object of the specified type
                else
                {
                    Assembly assembly = Assembly.LoadFrom(String.Format(@"{0}\{1}.dll", this.ResourcePath, task.Assembly));
                    objectToProcess = assembly.CreateInstance(task.TypeName);
                    _log.DebugFormat("Create non-persistent object: {0}", task.TypeName);
                }

                // execute the method on the relevant object
                objectToProcess.GetType().GetMethod(task.MethodName).Invoke(objectToProcess, new object[] { task.Args });

                // dispose the object if it's non-persistent
                if (!persistent && (objectToProcess as IDisposable) != null)
                {
                    (objectToProcess as IDisposable).Dispose();
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("Error occured while executing task {0}:{1}\n{2}\nAssembly:{3}\nType:{4}\nMethod:{5}"
                                 , task.TaskId, e.Message, e.StackTrace, task.Assembly, task.TypeName, task.MethodName);
            }
            finally
            {
                // mark engine as idle for the taskbroker
                TaskBroker.UpdateEngineStatus(this.EngineId, EngineStatus.Idle);
            }
        }
Exemple #4
0
	// Use this for initialization
	void Start () {
        UpdateClockDisplay();
        SetSpeed(0);
        taskBrokerScript = taskBroker.GetComponent<TaskBroker>();
     }