public void TestAutoInit()
        {
            Tester ref1 = null;
            Tester ref2 = null;

            Assert.IsNotNull(AutoInit.Ref(ref ref1));
            Assert.IsNotNull(AutoInit.Ref(ref ref1));
            Assert.AreEqual(0, ref1.A);
            Assert.IsNotNull(AutoInit.Ref(ref ref2, 10));
            Assert.IsNotNull(AutoInit.Ref(ref ref2, 10));
            Assert.AreEqual(10, ref2.A);
            Assert.AreEqual(2, Tester.ConstructorCallCount);
        }
Example #2
0
        public Client()
        {
            AutoInit.Init();
            MqttAdaptor = new MqttAdaptor(ConfigManager.MQIP(), ConfigManager.MQTTPort(),
                                          ConfigManager.MQUser(), ConfigManager.MQPass());
            GateAdaptor = new GateAdaptor("127.0.0.1", 6888);

            MqttAdaptor.Connected += () =>
            {
                BeginTest();
            };
            MqttAdaptor.BeginReceive();
            GateAdaptor.BeginReceive();
        }
Example #3
0
        static void InitService()
        {
            AutoInit.Init();

            RoutingRule.DistrictsName = "test";

            GateAdaptor = new GateAdaptor("127.0.0.1", 6999);

            ServiceImplementStub.Bind <ICli2SceneImpl>(GateAdaptor, new SceneClientServiceImpl());

            Scene2CliService = new Scene2CliServiceDelegate(GateAdaptor);

            GateAdaptor.BeginReceive();
            //Heartbeat();
        }
Example #4
0
        static void Main(string[] args)
        {
            AutoInit.Init();
            AmqpAdaptor AmqpAdaptor = new AmqpAdaptor(ConfigManager.MQIP(), ConfigManager.AMQPPort(),
                                                      ConfigManager.MQUser(), ConfigManager.MQPass());

            ServiceImplementStub.Bind <ICli2LoginImpl>(AmqpAdaptor, new LoginClientServiceImpl());
            ServiceImplementStub.Bind <ILoginNotifyImpl>(AmqpAdaptor, new LoginNotifyImpl());
            AmqpAdaptor.BeginReceive();

            RedisAdaptor     = new RedisAdaptor(ConfigManager.CacheConn());
            CacheDataService = new RedisDataServiceDelegate(RedisAdaptor);

            Console.ReadKey();
        }
Example #5
0
        static void InitService()
        {
            AutoInit.Init();
            TypeRegister.Init();

            RoutingRule.DistrictsName = ConfigManager.DistrictsName();

            zkAdaptor = new ZkAdaptor();
            //amqpAdaptor = new AmqpAdaptor(ConfigManager.MQIP(), ConfigManager.AMQPPort(),
            //    ConfigManager.MQUser(), ConfigManager.MQPass());

            //ServiceImplementStub.Bind<LogicClientServiceImpl, ILogicClientImpl>(amqpAdaptor, new LogicClientServiceImpl());
            ServiceImplementStub.Bind <IDbClientNotifyImpl>(zkAdaptor, new NotifyServiceImpl());

            //Logic2CliService = new ClientLogicServiceDelegate(amqpAdaptor);
            //loginNotifyDelegate = new LoginNotifyDelegate(amqpAdaptor);
            //SchedulerLogicService = new SchedulerLogicServiceDelegate(amqpAdaptor);

            dbClientNotifyDelegate = new DbClientNotifyDelegate(zkAdaptor);

            //ConfigManager.RegisterParser(new ConfigManager.ConfigParserDelegate<EndPoint>(s =>
            //{
            //    var rets = s.Split(':');
            //    var host = rets[0];
            //    var port = 0;

            //    int.TryParse(rets[1], out port);

            //    IPAddress ip;
            //    if (IPAddress.TryParse(host, out ip))
            //    {
            //        return new IPEndPoint(ip, port);
            //    }

            //    return new DnsEndPoint(host, port);
            //}));

            CacheService = new RedisDataServiceDelegate(new RedisAdaptor(ConfigManager.Instance.Read <List <EndPoint> >("DataService", "CacheConn")));
            //DbService = new MysqlDataServiceDelegate(new MysqlAdaptor(ConfigManager.DbIP(), ConfigManager.DbName(), ConfigManager.DbUser(), ConfigManager.DbPass()));

            zkAdaptor.BeginReceive();
            //amqpAdaptor.BeginReceive();

            zkAdaptor.Identity("Logic");

            //Heartbeat();
        }
Example #6
0
        static void InitService()
        {
            AutoInit.Init();

            zkAdaptor   = new ZkAdaptor();
            amqpAdaptor = new AmqpAdaptor(ConfigManager.MQIP(), ConfigManager.AMQPPort(),
                                          ConfigManager.MQUser(), ConfigManager.MQPass());

            ServiceImplementStub.Bind <IWatcherServiceNotifyImpl>(amqpAdaptor, new WatcherServiceImpl());

            //dbClientNotifyDelegate = new DbClientNotifyDelegate(zkAdaptor);
            watcherServiceNotifyDelegate = new WatcherServiceNotifyDelegate(amqpAdaptor);

            amqpAdaptor.BeginReceive();
            zkAdaptor.BeginReceive();

            var toWatch     = ConfigManager.Instance.Read <int>("WatcherService", "WatchNum");
            var watchGroups = new List <WatchGroup>();

            for (int i = 1; i <= toWatch; i++)
            {
                var group = new WatchGroup()
                {
                    GroupName       = ConfigManager.Instance.Read <string>("WatcherService", "WatchName" + i),
                    Quorum          = ConfigManager.Instance.Read <int>("WatcherService", "WatchQuorum" + i),
                    DownAfterPeriod = ConfigManager.Instance.Read <int>("WatcherService", "WatchDownAfter" + i),
                    ParallelSync    = ConfigManager.Instance.Read <int>("WatcherService", "WatchParallelSync" + i),
                    FailoverTime    = ConfigManager.Instance.Read <int>("WatcherService", "WatchFailoverTimeout" + i),
                };

                group.SetCurrentMaster(new MasterInstance(group)
                {
                    EndPoint = ConfigManager.Instance.Read <EndPoint>("WatcherService", "WatchAddr" + i),
                });

                watchGroups.Add(group);
            }

            watcherManager = new WatcherManager(watchGroups);
        }
Example #7
0
 private static IntPtr internalInitialize()
 {
     deterministicStaticInit();
     ai = new AutoInit();
     return(modID);
 }
 private static IntPtr internalInitialize()
 {
     deterministicStaticInit();
     ai = new AutoInit();
     return modID;
 }