Beispiel #1
0
        private Soul _NewSoul(object soul, Type soul_type)
        {
            MemberMap map         = _Protocol.GetMemberMap();
            int       interfaceId = map.GetInterface(soul_type);
            Soul      newSoul     = new Soul(_IdLandlord.Rent(), interfaceId, soul_type, soul);



            // property
            PropertyInfo[] propertys = soul_type.GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public);

            for (int i = 0; i < propertys.Length; ++i)
            {
                PropertyInfo property = propertys[i];
                int          id       = map.GetProperty(property);

                if (property.PropertyType.GetInterfaces().Any(t => t == typeof(IDirtyable)))
                {
                    object     propertyValue = property.GetValue(soul);
                    IDirtyable dirtyable     = propertyValue as IDirtyable;

                    PropertyUpdater pu = new PropertyUpdater(dirtyable, id);
                    newSoul.AddPropertyUpdater(pu);
                }
            }

            _Souls.Add(newSoul);

            return(newSoul);
        }
 protected override void Initialize()
 {
     m_frontend = new RouterSocket(m_frontendAddress);
     m_backend  = new RouterSocket(m_backendAddress);
     m_frontend.ReceiveReady += OnFrontendReady;
     m_backend.ReceiveReady  += OnBackendReady;
     Poller.Add(m_backend);
     Poller.Add(m_frontend);
 }
Beispiel #3
0
        /// <summary>
        /// Facade constructor calling the base class constructor, and initializing the Router socket.
        /// </summary>
        public Facade() : base()
        {
            _routerSocket = new RouterSocket();

            Subscribe("Response", SendResponse);
            Subscribe("Error", SendResponse);

            Poller.Add(_routerSocket);
        }
Beispiel #4
0
        private Soul _NewSoul(object soul, Type soul_type)
        {
            var map         = _Protocol.GetMemberMap();
            var interfaceId = map.GetInterface(soul_type);
            var new_soul    = new Soul
            {
                ID             = Guid.NewGuid(),
                InterfaceId    = interfaceId,
                ObjectType     = soul_type,
                ObjectInstance = soul,
                MethodInfos    = soul_type.GetMethods()
            };

            // event
            var eventInfos = soul_type.GetEvents();

            new_soul.EventHandlers = new List <Soul.EventHandler>();

            foreach (var eventInfo in eventInfos)
            {
                //var handler = _BuildDelegate(genericArguments, new_soul.ID, eventInfo.Name, _InvokeEvent);

                try
                {
                    var handler = _BuildDelegate(eventInfo, new_soul.ID, _InvokeEvent);

                    var eh = new Soul.EventHandler();
                    eh.EventInfo      = eventInfo;
                    eh.DelegateObject = handler;
                    new_soul.EventHandlers.Add(eh);

                    var addMethod = eventInfo.GetAddMethod();
                    addMethod.Invoke(soul, new[] { handler });
                }
                catch (Exception ex)
                {
                    Regulus.Utility.Log.Instance.WriteDebug(ex.ToString());
                    throw ex;
                }
            }

            // property
            var propertys = soul_type.GetProperties(BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public);

            new_soul.PropertyHandlers = new Soul.PropertyHandler[propertys.Length];
            for (var i = 0; i < propertys.Length; ++i)
            {
                var property = propertys[i];
                var id       = map.GetProperty(property);
                new_soul.PropertyHandlers[i] = new Soul.PropertyHandler(property, id);
            }

            _Souls.Add(new_soul);

            return(new_soul);
        }
Beispiel #5
0
        protected override void Initialize()
        {
            m_clientSocket = new DealerSocket();
            m_clientSocket.Connect(m_address);
            m_clientSocket.ReceiveReady += OnSocketReady;
            Poller.Add(m_clientSocket);

            m_outgoingQueue.ReceiveReady += OnOutgoingQueueReady;
            Poller.Add(m_outgoingQueue);
        }
Beispiel #6
0
        private NetMQActor CreateActor()
        {
            return(NetMQActor.Create(shim =>
            {
                Shim = shim;
                Shim.ReceiveReady += ShimOnReceiveReady;
                Shim.SignalOK();

                Poller.Add(Shim);
                Poller.Add(ListeningSocket);
                Poller.Run();

                Log("Node closed");
            }));
        }
Beispiel #7
0
        private NetMQActor CreateActor()
        {
            return(NetMQActor.Create(shim =>
            {
                Shim = shim;
                Shim.ReceiveReady += ShimOnReceiveReady;

                Poller.Add(ListeningSocket);
                Poller.Add(InitTimer);
                Poller.Add(Shim);

                Shim.SignalOK();
                Poller.Run();
            }));
        }
Beispiel #8
0
        /// <summary>
        /// 启用路由Poller
        /// </summary>
        public static void RunAsync()
        {
            if (Poller.IsRunning)
            {
                return;
            }

            router.Bind(ServerAddress.RouterAddress);
            router.ReceiveReady += Router_ReceiveReady;
            //  dealer.ReceiveReady += Dealer_ReceiveReady;
            Poller.Add(router);
            //  Poller.Add(dealer);
            Poller.Add(new NetMQTimer(Timeout));
            Poller.RunAsync();
            //此处需要传入Poller,否则Proxy.Start会以同步方式启动
            //    NetMQ.Proxy proxy = new Proxy(router, dealer, null, Poller);
            //     proxy.Start();
        }
 protected override void Initialize()
 {
     m_workerSocket = new DealerSocket(m_loadbalancerAddress);
     m_workerSocket.ReceiveReady += OnWorkerReady;
     Poller.Add(m_workerSocket);
 }
 public PublisherService() : base(new PublisherSocket())
 {
     Queue = new NetMQQueue <IInvocation>();
     Poller.Add(Queue);
     Queue.ReceiveReady += Queue_ReceiveReady;
 }
 public ServiceHost() : base(new RouterSocket())
 {
     Poller.Add(Socket);
     Socket.ReceiveReady += Socket_ReceiveReady;
 }
 public SubscriptionServiceHost() : base(new SubscriberSocket())
 {
     Poller.Add(Socket);
     Socket.ReceiveReady += Socket_ReceiveReady;
 }
Beispiel #13
0
 protected override void Initialize()
 {
     m_serverSocket = new RouterSocket();
     m_serverSocket.ReceiveReady += OnSocketReady;
     Poller.Add(m_serverSocket);
 }