예제 #1
0
 public hub_msg_handle(hubmanager _hubmanager_, mongodbproxy _mongodbproxy_)
 {
     _hubmanager   = _hubmanager_;
     _mongodbproxy = _mongodbproxy_;
 }
예제 #2
0
 public logic_msg_handle(logicmanager _logicmanager_, mongodbproxy _mongodbproxy_, closehandle _closehandle_)
 {
     _logicmanager = _logicmanager_;
     _mongodbproxy = _mongodbproxy_;
     _closehandle  = _closehandle_;
 }
예제 #3
0
파일: dbproxy.cs 프로젝트: micules/abelkhan
        public dbproxy(String[] args)
        {
            is_busy = false;

            uuid = System.Guid.NewGuid().ToString();

            config.config _config        = new config.config(args[0]);
            config.config _center_config = _config.get_value_dict("center");
            if (args.Length > 1)
            {
                _config = _config.get_value_dict(args[1]);
            }

            closeHandle = new closehandle();

            var db_ip      = _config.get_value_string("db_ip");
            var db_port    = (short)_config.get_value_int("db_port");
            var db         = _config.get_value_string("db_name");
            var collection = _config.get_value_string("db_collection");

            _mongodbproxy = new mongodbproxy(db_ip, db_port, db, collection);

            var ip   = _config.get_value_string("ip");
            var port = (short)_config.get_value_int("port");

            _hub_call_dbproxy = new module.hub_call_dbproxy();
            _hub_process      = new juggle.process();
            _hub_process.reg_module(_hub_call_dbproxy);
            _hub_acceptnetworkservice = new service.acceptnetworkservice(ip, port, _hub_process);
            _hubmanager                  = new hubmanager();
            _hub_msg_handle              = new hub_msg_handle(_hubmanager, _mongodbproxy);
            _hub_call_dbproxy.onreg_hub += _hub_msg_handle.reg_hub;
            _hub_call_dbproxy.oncreate_persisted_object += _hub_msg_handle.create_persisted_object;
            _hub_call_dbproxy.onupdata_persisted_object += _hub_msg_handle.updata_persisted_object;
            _hub_call_dbproxy.onget_object_info         += _hub_msg_handle.get_object_info;

            _logic_call_dbproxy         = new module.logic_call_dbproxy();
            _logic_process              = new juggle.process();
            _logic_acceptnetworkservice = new service.acceptnetworkservice(ip, port, _logic_process);
            _logicmanager     = new logicmanager();
            _logic_msg_handle = new logic_msg_handle(_logicmanager, _mongodbproxy, closeHandle);
            _logic_call_dbproxy.onreg_logic               += _logic_msg_handle.reg_logic;
            _logic_call_dbproxy.onlogic_closed            += _logic_msg_handle.logic_closed;
            _logic_call_dbproxy.oncreate_persisted_object += _logic_msg_handle.create_persisted_object;
            _logic_call_dbproxy.onupdata_persisted_object += _logic_msg_handle.updata_persisted_object;
            _logic_call_dbproxy.onget_object_info         += _logic_msg_handle.get_object_info;

            var center_ip   = _center_config.get_value_string("ip");
            var center_port = (short)_center_config.get_value_int("port");

            _center_call_server = new module.center_call_server();
            _center_process     = new juggle.process();
            _center_process.reg_module(_center_call_server);
            _center_connectnetworkservice = new service.connectnetworkservice(_center_process);
            var _center_ch = _center_connectnetworkservice.connect(center_ip, center_port);

            _centerproxy       = new centerproxy(_center_ch);
            _center_msg_handle = new center_msg_handle(closeHandle, _centerproxy);
            _center_call_server.onclose_server      += _center_msg_handle.close_server;
            _center_call_server.onreg_server_sucess += _center_msg_handle.reg_server_sucess;

            _juggle_service = new service.juggleservice();
            _juggle_service.add_process(_hub_process);
            _juggle_service.add_process(_logic_process);
            _juggle_service.add_process(_center_process);

            timer = new service.timerservice();

            _centerproxy.reg_dbproxy(ip, port, uuid);
        }
예제 #4
0
        public dbproxy(String[] args)
        {
            is_busy = false;

            uuid = System.Guid.NewGuid().ToString();

            config.config _config        = new config.config(args[0]);
            config.config _center_config = _config.get_value_dict("center");
            if (args.Length > 1)
            {
                _config = _config.get_value_dict(args[1]);
            }

            var log_level = _config.get_value_string("log_level");

            if (log_level == "debug")
            {
                log.log.logMode = log.log.enLogMode.Debug;
            }
            else if (log_level == "release")
            {
                log.log.logMode = log.log.enLogMode.Release;
            }
            var log_file = _config.get_value_string("log_file");

            log.log.logFile = log_file;
            var log_dir = _config.get_value_string("log_dir");

            log.log.logPath = log_dir;
            {
                if (!System.IO.Directory.Exists(log_dir))
                {
                    System.IO.Directory.CreateDirectory(log_dir);
                }
            }

            closeHandle = new closehandle();

            var db_ip      = _config.get_value_string("db_ip");
            var db_port    = (short)_config.get_value_int("db_port");
            var db         = _config.get_value_string("db_name");
            var collection = _config.get_value_string("db_collection");

            _mongodbproxy = new mongodbproxy(db_ip, db_port, db, collection);

            var ip   = _config.get_value_string("ip");
            var port = (short)_config.get_value_int("port");

            _logic_call_dbproxy = new module.logic_call_dbproxy();
            _hub_call_dbproxy   = new module.hub_call_dbproxy();
            _process            = new juggle.process();
            _process.reg_module(_logic_call_dbproxy);
            _process.reg_module(_hub_call_dbproxy);
            _acceptnetworkservice = new service.acceptnetworkservice(ip, port, _process);

            _hubmanager                  = new hubmanager();
            _hub_msg_handle              = new hub_msg_handle(_hubmanager, _mongodbproxy);
            _hub_call_dbproxy.onreg_hub += _hub_msg_handle.reg_hub;
            _hub_call_dbproxy.oncreate_persisted_object += _hub_msg_handle.create_persisted_object;
            _hub_call_dbproxy.onupdata_persisted_object += _hub_msg_handle.updata_persisted_object;
            _hub_call_dbproxy.onget_object_info         += _hub_msg_handle.get_object_info;

            _logicmanager     = new logicmanager();
            _logic_msg_handle = new logic_msg_handle(_logicmanager, _mongodbproxy, closeHandle);
            _logic_call_dbproxy.onreg_logic               += _logic_msg_handle.reg_logic;
            _logic_call_dbproxy.onlogic_closed            += _logic_msg_handle.logic_closed;
            _logic_call_dbproxy.oncreate_persisted_object += _logic_msg_handle.create_persisted_object;
            _logic_call_dbproxy.onupdata_persisted_object += _logic_msg_handle.updata_persisted_object;
            _logic_call_dbproxy.onget_object_info         += _logic_msg_handle.get_object_info;

            var center_ip   = _center_config.get_value_string("ip");
            var center_port = (short)_center_config.get_value_int("port");

            _center_call_server = new module.center_call_server();
            _center_process     = new juggle.process();
            _center_process.reg_module(_center_call_server);
            _center_connectnetworkservice = new service.connectnetworkservice(_center_process);
            var _center_ch = _center_connectnetworkservice.connect(center_ip, center_port);

            _centerproxy       = new centerproxy(_center_ch);
            _center_msg_handle = new center_msg_handle(closeHandle, _centerproxy);
            _center_call_server.onclose_server      += _center_msg_handle.close_server;
            _center_call_server.onreg_server_sucess += _center_msg_handle.reg_server_sucess;

            _juggle_service = new service.juggleservice();
            _juggle_service.add_process(_process);
            _juggle_service.add_process(_center_process);

            timer = new service.timerservice();

            _centerproxy.reg_dbproxy(ip, port, uuid);
        }
예제 #5
0
        public dbproxy(String[] args)
        {
            is_busy = false;

            uuid = System.Guid.NewGuid().ToString();

            config.config _config        = new config.config(args[0]);
            config.config _center_config = _config.get_value_dict("center");
            if (args.Length > 1)
            {
                _config = _config.get_value_dict(args[1]);
            }

            var log_level = _config.get_value_string("log_level");

            if (log_level == "debug")
            {
                log.log.logMode = log.log.enLogMode.Debug;
            }
            else if (log_level == "release")
            {
                log.log.logMode = log.log.enLogMode.Release;
            }
            var log_file = _config.get_value_string("log_file");

            log.log.logFile = log_file;
            var log_dir = _config.get_value_string("log_dir");

            log.log.logPath = log_dir;
            {
                if (!System.IO.Directory.Exists(log_dir))
                {
                    System.IO.Directory.CreateDirectory(log_dir);
                }
            }

            closeHandle = new closehandle();

            _dbevent = new dbevent();
            _dbevent.start();

            if (_config.has_key("db_ip") && _config.has_key("db_port"))
            {
                var db_ip   = _config.get_value_string("db_ip");
                var db_port = (short)_config.get_value_int("db_port");

                _mongodbproxy = new mongodbproxy(db_ip, db_port);
            }
            else if (_config.has_key("db_url"))
            {
                _mongodbproxy = new mongodbproxy(_config.get_value_string("db_url"));
            }

            if (_config.has_key("index"))
            {
                var _index_config = _config.get_value_list("index");
                for (int i = 0; i < _index_config.get_list_size(); i++)
                {
                    var index      = _index_config.get_list_dict(i);
                    var db         = index.get_value_string("db");
                    var collection = index.get_value_string("collection");
                    var key        = index.get_value_string("key");
                    var is_unique  = index.get_value_bool("is_unique");
                    _mongodbproxy.create_index(db, collection, key, is_unique);
                }
            }

            var ip   = _config.get_value_string("ip");
            var port = (short)_config.get_value_int("port");

            _hub_call_dbproxy = new module.hub_call_dbproxy();
            _process          = new juggle.process();
            _process.reg_module(_hub_call_dbproxy);
            _acceptnetworkservice = new service.acceptnetworkservice(ip, port, _process);

            _hubmanager                  = new hubmanager();
            _hub_msg_handle              = new hub_msg_handle(_hubmanager, _mongodbproxy);
            _hub_call_dbproxy.onreg_hub += _hub_msg_handle.reg_hub;
            _hub_call_dbproxy.oncreate_persisted_object += _hub_msg_handle.create_persisted_object;
            _hub_call_dbproxy.onupdata_persisted_object += _hub_msg_handle.updata_persisted_object;
            _hub_call_dbproxy.onget_object_count        += _hub_msg_handle.get_object_count;
            _hub_call_dbproxy.onget_object_info         += _hub_msg_handle.get_object_info;
            _hub_call_dbproxy.onremove_object           += _hub_msg_handle.remove_object;

            var center_ip   = _center_config.get_value_string("ip");
            var center_port = (short)_center_config.get_value_int("port");

            _center_call_server = new module.center_call_server();
            _center_process     = new juggle.process();
            _center_process.reg_module(_center_call_server);
            _center_connectnetworkservice = new service.connectnetworkservice(_center_process);
            var _center_ch = _center_connectnetworkservice.connect(center_ip, center_port);

            _centerproxy       = new centerproxy(_center_ch);
            _center_msg_handle = new center_msg_handle(closeHandle, _centerproxy);
            _center_call_server.onclose_server      += _center_msg_handle.close_server;
            _center_call_server.onreg_server_sucess += _center_msg_handle.reg_server_sucess;

            _juggle_service = new service.juggleservice();
            _juggle_service.add_process(_process);
            _juggle_service.add_process(_center_process);

            timer = new service.timerservice();

            _centerproxy.reg_dbproxy(ip, port, uuid);
        }