コード例 #1
0
        public static void Main(string[] args)
        {
            INode node = NodeFactory.Default;

            node.Loger.Type = LogType.ALL;
            node.AddLogHandler(new SmartRoute.ConsoleLogHandler(LogType.ALL));
            node.Open();
            EventSubscriber ken = node.Register <EventSubscriber>("ken");

            ken.Register <User>(OnUser);
            ken.Register <Employee>(OnEmployees);
            node.SubscriberRegisted = (n, s) =>
            {
                if (s.Name == "henry")
                {
                    ken.Publish("henry", Employee.GetEmployee());
                }
            };

            while (true)
            {
                Console.WriteLine(mCount);
                System.Threading.Thread.Sleep(1000);
            }
            Console.Read();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            INode node = NodeFactory.Default;

            node.Loger.Type = LogType.ALL;
            node.AddLogHandler(new ConsoleLogHandler(LogType.ALL));
            node.Open();
            EventSubscriber ken = node.Register <EventSubscriber>("ken");

            node.SubscriberRegisted += (n, s) =>
            {
                if (s.Name == "henry")
                {
                    System.Threading.ThreadPool.QueueUserWorkItem(o =>
                    {
                        while (true)
                        {
                            Employee result = ken.Publish <Employee>("henry", Employee.GetEmployee());
                            if (result == null)
                            {
                                throw new Exception("error");
                            }
                            System.Threading.Interlocked.Increment(ref mCount);
                        }
                    });
                }
            };
            while (true)
            {
                Console.WriteLine("{0}/秒|{1}", mCount - mLastCount, mCount);
                mLastCount = mCount;
                System.Threading.Thread.Sleep(1000);
            }
            Console.Read();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: qcjxberin/SmartRoute
        private static void ToKen(object state)
        {
            EventSubscriber henry = (EventSubscriber)state;

            while (true)
            {
                henry.Publish("ken", Employee.GetEmployee());
                System.Threading.Thread.Sleep(1);
            }
        }
コード例 #4
0
        public string Create(string expression)
        {
            Request request = new BNR.Request();

            request.Expression = expression;

            Response response = mEventSubscriber.Publish <Response>(NBRServer.NBR_SERVER_TAG, request, 5000);

            if (!string.IsNullOrEmpty(response.Error))
            {
                throw new Exception(response.Error);
            }
            return(response.Value);
        }