Пример #1
0
 public client_msg_handle(clientmanager _clientmanager_, logicmanager _logicmanager_, hubmanager _hubmanager_, service.timerservice _timerservice_)
 {
     _clientmanager = _clientmanager_;
     _logicmanager  = _logicmanager_;
     _hubmanager    = _hubmanager_;
     _timerservice  = _timerservice_;
 }
Пример #2
0
        public gate(String[] args)
        {
            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();

            enable_heartbeats = _config.get_value_bool("heartbeats");

            timer       = new service.timerservice();
            _hubmanager = new hubmanager();
            clients     = new clientmanager();

            _client_msg_handle = new client_msg_handle(clients, _hubmanager, timer);
            _client_call_gate  = new module.client_call_gate();
            _client_call_gate.onconnect_server          += _client_msg_handle.connect_server;
            _client_call_gate.oncancle_server           += _client_msg_handle.cancle_server;
            _client_call_gate.onconnect_hub             += _client_msg_handle.connect_hub;
            _client_call_gate.ondisconnect_hub          += _client_msg_handle.disconnect_hub;
            _client_call_gate.onforward_client_call_hub += _client_msg_handle.forward_client_call_hub;
            _client_call_gate.onheartbeats += _client_msg_handle.heartbeats;
            var _client_process = new juggle.process();

            _client_process.reg_module(_client_call_gate);

            var outside_ip   = _config.get_value_string("outside_ip");
            var outside_port = (short)_config.get_value_int("outside_port");

            _accept_client_service = new service.acceptnetworkservice(outside_ip, outside_port, _client_process);
            _accept_client_service.onChannelDisconnect += onClientDissconnect;

            _hub_msg_handle                                  = new hub_msg_handle(_hubmanager, clients);
            _hub_call_gate                                   = new module.hub_call_gate();
            _hub_call_gate.onreg_hub                        += _hub_msg_handle.reg_hub;
            _hub_call_gate.onconnect_sucess                 += _hub_msg_handle.connect_sucess;
            _hub_call_gate.ondisconnect_client              += _hub_msg_handle.disconnect_client;
            _hub_call_gate.onforward_hub_call_client        += _hub_msg_handle.forward_hub_call_client;
            _hub_call_gate.onforward_hub_call_global_client += _hub_msg_handle.forward_hub_call_global_client;
            _hub_call_gate.onforward_hub_call_group_client  += _hub_msg_handle.forward_hub_call_group_client;

            var _logic_hub_process = new juggle.process();

            _logic_hub_process.reg_module(_hub_call_gate);
            var inside_ip   = _config.get_value_string("inside_ip");
            var inside_port = (short)_config.get_value_int("inside_port");

            _accept_logic_hub_service = new service.acceptnetworkservice(inside_ip, inside_port, _logic_hub_process);

            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();
            var _center_process = new juggle.process();

            _center_process.reg_module(_center_call_server);
            _connect_center_service = new service.connectnetworkservice(_center_process);
            var center_ch = _connect_center_service.connect(center_ip, center_port);

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

            _juggle_service = new service.juggleservice();
            _juggle_service.add_process(_logic_hub_process);
            _juggle_service.add_process(_center_process);
            _juggle_service.add_process(_client_process);

            _centerproxy.reg_gate(inside_ip, inside_port, uuid);

            if (enable_heartbeats)
            {
                timer.addticktime(60 * 1000, clients.tick_client);
            }
        }
Пример #3
0
 public hub_msg_handle(hubmanager _hubmanager_, clientmanager _clientmanager_)
 {
     _hubmanager    = _hubmanager_;
     _clientmanager = _clientmanager_;
 }
Пример #4
0
        public gate(String[] args)
        {
            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();

            timer              = new service.timerservice();
            _logicmanager      = new logicmanager();
            _clientmanager     = new clientmanager();
            _client_msg_handle = new client_msg_handle(_clientmanager, _logicmanager, timer);
            _client_call_gate  = new module.client_call_gate();
            _client_call_gate.onconnect_server            += _client_msg_handle.connect_server;
            _client_call_gate.oncancle_server             += _client_msg_handle.cancle_server;
            _client_call_gate.onforward_client_call_logic += _client_msg_handle.forward_client_call_logic;
            _client_call_gate.onheartbeats += _client_msg_handle.heartbeats;
            var _client_process = new juggle.process();

            _client_process.reg_module(_client_call_gate);


            var outside_ip   = _config.get_value_string("outside_ip");
            var outside_port = (short)_config.get_value_int("outside_port");

            _accept_client_service = new service.acceptnetworkservice(outside_ip, outside_port, _client_process);

            _logic_msg_handle             = new logic_msg_handle(_logicmanager, _clientmanager);
            _logic_call_gate              = new module.logic_call_gate();
            _logic_call_gate.onreg_logic += _logic_msg_handle.reg_logic;
            _logic_call_gate.onack_client_connect_server        += _logic_msg_handle.ack_client_connect_server;
            _logic_call_gate.onforward_logic_call_client        += _logic_msg_handle.forward_logic_call_client;
            _logic_call_gate.onforward_logic_call_global_client += _logic_msg_handle.forward_logic_call_global_client;
            _logic_call_gate.onforward_logic_call_group_client  += _logic_msg_handle.forward_logic_call_group_client;

            _hubmanager               = new hubmanager();
            _hub_msg_handle           = new hub_msg_handle(_hubmanager, _clientmanager);
            _hub_call_gate            = new module.hub_call_gate();
            _hub_call_gate.onreg_hub += _hub_msg_handle.reg_hub;
            //_hub_call_gate.onforward_hub_call_client += _hub_msg_handle.forward_hub_call_client;
            _hub_call_gate.onforward_hub_call_global_client += _hub_msg_handle.forward_hub_call_global_client;
            _hub_call_gate.onforward_hub_call_group_client  += _hub_msg_handle.forward_hub_call_group_client;

            var _logic_hub_process = new juggle.process();

            _logic_hub_process.reg_module(_logic_call_gate);
            _logic_hub_process.reg_module(_hub_call_gate);
            var inside_ip   = _config.get_value_string("inside_ip");
            var inside_port = (short)_config.get_value_int("inside_port");

            _accept_logic_hub_service = new service.acceptnetworkservice(inside_ip, inside_port, _logic_hub_process);

            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();
            var _center_process = new juggle.process();

            _center_process.reg_module(_center_call_server);
            _connect_center_service = new service.connectnetworkservice(_center_process);
            var center_ch = _connect_center_service.connect(center_ip, center_port);

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

            _juggle_service = new service.juggleservice();
            _juggle_service.add_process(_logic_hub_process);
            _juggle_service.add_process(_center_process);
            _juggle_service.add_process(_client_process);

            _centerproxy.reg_gate(inside_ip, inside_port, uuid);
        }