コード例 #1
0
 def __init__(self):
     CAppBase.__init__(self)
     self.server_user_dict = {
     }  # server group id -> {server_user_id: connect_id},方便统计在线人数
     self.user_login_time_dict = {}  # server_user_id -> login time
     self.chat_msg_count = 0
     self.notice_msg_count = 0
コード例 #2
0
    def __init__(self):
        CAppBase.__init__(self)
        self.ctrpcHandler = Ct2DbRpcHandler()
        self.tmrpcHandler = Tm2DbRpcHandler()
        self.ftrpcHandler = Ft2DbRpcHandler()
        self.scene_rpc_handler = Scene2DbRpcHandler()

        self.threadPool = {}  # threadType -> threadpool
        self.queryrpcMgr = CQueryRpcMgr()
コード例 #3
0
 def __init__(self):
     CAppBase.__init__(self)
     self.user_connect_dict = {
     }  # 保存玩家角色id到连接id的映射 server user id -> connect id
     self.connect_info_dict = {}  # 连接信息字典 connect id -> ClientConnect obj
     self.group_connect_dict = {
     }  # 按服区分的连接映射 server group id -> connect id dict
     self.client_msg_handler = CGw4CliMsgHandler()  # 接收处理客户端消息
     self.msg_manager = GatewayMsgManager()  # 处理本节点需要处理的消息
     self.game_server_connect = {}  # 游戏服连接connect id -> rk_zone
コード例 #4
0
 def __init__(self):
     CAppBase.__init__(self)
     self.scene_msg_count = 0
     self.channel_id_counter = {
     }  # channel计数器, server_group_id => channel id counter
     self.user_map_channel = {
     }  # 玩家所在场景, server_user_id => (server group id, channel id)
     self.channel_user_list = {
     }  # 场景玩家数量统计, server group id => channel id => [server_user_id, ...]
     self.team_bind_channel = {
     }  # 队伍绑定的场景, team id => (server group id, channel id)
     self.channel_bind_team = {
     }  # 场景所属的队伍, server group id => channel id => team id
     self.channel_map_node = {
     }  # 场景对应的场景服务器, server group id => channel id => scene node id
コード例 #5
0
 def OnClientRpcMsg(self, service_type, conn_id, proto, msg_str):
     if service_type == ModTopo.SERVICE_TYPE.FOR_CLIENT:
         # 是客户端发来的消息
         if proto == ModTopo.PROTO_TYPE.COMMON:
             # common 类型协议,网关自己处理
             self.get_client_msg_handler().OnClientCommonMsg(
                 conn_id, msg_str)
             return
         if proto == ModTopo.PROTO_TYPE.CHAT:
             # 普通聊天类型协议
             self.get_client_msg_handler().OnClientChatMsg(conn_id, msg_str)
         elif proto == ModTopo.PROTO_TYPE.TEAM:
             # 组队协议
             self.get_client_msg_handler().OnClientTeamMsg(conn_id, msg_str)
         elif proto == ModTopo.PROTO_TYPE.FIGHT:
             self.get_client_msg_handler().OnClientBattleMsg(
                 conn_id, msg_str)
         elif proto == ModTopo.PROTO_TYPE.SCENE:
             self.get_client_msg_handler().OnClientSceneMsg(
                 conn_id, msg_str)
         else:
             logger.GetLog().warn(
                 'OnClientMsg from client %s receive unexpected proto : %s'
                 % (conn_id, proto))
         return
     else:
         # 是节点发来的消息
         CAppBase.OnClientRpcMsg(self, service_type, conn_id, proto,
                                 msg_str)
コード例 #6
0
 def OnClientConnected(self, service_type, conn_id, ip):
     logger.GetLog().debug('OnClientConnected : %s, %s, %s' %
                           (service_type, conn_id, ip))
     if service_type == ModTopo.SERVICE_TYPE.FOR_CLIENT:
         # 是客户端连接
         self.connect_info_dict[conn_id] = ClientConnect(conn_id)
     CAppBase.OnClientConnected(self, service_type, conn_id, ip)
コード例 #7
0
    def OnStartUp(self, config_file):
        # 移除json的钩子,因为 ujson不支持separators关键字,会在couchbase sdk中调用时报错
        import script.common.initscript as init_script
        init_script.HOOK_MODULES.pop('json', None)
        import couchbase._bootstrap
        reload(couchbase._bootstrap)

        CAppBase.OnStartUp(self, config_file)
        self.init_thread_pool()
コード例 #8
0
    def OnStartUp(self, conf_file):
        # 移除json的钩子,因为ujson不支持separators关键字,会在couchbase sdk中调用时报错
        import script.common.initscript as init_script
        init_script.HOOK_MODULES.pop('json', None)
        import couchbase._bootstrap
        reload(couchbase._bootstrap)

        CAppBase.OnStartUp(self, conf_file)
        self.InitThreadPool()

        # 初始化战斗常量配置数据
        masters_global.init_battle_config_const_value()
コード例 #9
0
 def OnServerRpcMsg(self, t_cli, connid, proto, msgstr):
     if t_cli == ModTopo.NODE_TYPE.GATEWAY:
         #客户端不支持rpc通信,需要自己实现此方法
         logger.GetLog().debug(
             'OnRpcMsg connect_id : %s, proto : %s, msg : %s' %
             (connid, proto, msgstr))
         msg = msgpack.unpackb(msgstr)
         if msg[proto_def.field_name_cmd] == proto_def.cg_login_server:
             self.OnLoginResponse(CGLoginServerResponse.new_from_data(msg))
         elif msg[proto_def.
                  field_name_cmd] == proto_def.cg_game_server_register:
             self.OnLoginResponse(
                 CGGameServerRegisterResponse.new_from_data(msg))
     CAppBase.OnServerRpcMsg(self, t_cli, connid, proto, msgstr)
コード例 #10
0
 def __init__(self):
     CAppBase.__init__(self)
     self.team_manager = TeamManager()
コード例 #11
0
 def OnConnectToServer(self, t_cli, connid, ip):
     CAppBase.OnConnectToServer(self, t_cli, connid, ip)
     if self.get_test_param('client_type') == 2:
         self.TestGameServerLogin()
     else:
         self.TestUserLogin()
コード例 #12
0
 def OnStartUp(self, conf_file):
     CAppBase.OnStartUp(self, conf_file)
     # 启动定时器并注册事件
     self.RegTick(self._sec_tick, None, 1000)
     self._register_sec_tick_handler(self.battle_manager.battle_sec_timer)
     self.RegTick(self._battle_sync_tick, None, 200)
コード例 #13
0
 def __init__(self):
     CAppBase.__init__(self)
     self.chatTimes = 0
コード例 #14
0
 def OnStartUp(self, conf_file):
     CAppBase.OnStartUp(self, conf_file)
     # 启动在线人数日志定时器并注册事件
     self.RegTick(self._timer_online_num_log, None, 300000)
コード例 #15
0
 def __init__(self):
     CAppBase.__init__(self)
     self.thread_pool_dict = {}  # thread_type -> thread_pool
コード例 #16
0
 def __init__(self):
     CAppBase.__init__(self)
     self.online_manager = OnlineUserManager()
     self.temp_public_msg_dict = {}
コード例 #17
0
 def OnStartUp(self, conf_file):
     CAppBase.OnStartUp(self, conf_file)
     # 启动回写定时器
     self.RegTick(self._write_back_timer, None, 5000)
コード例 #18
0
 def OnConnectToServerFailed(self, t_cli, errmsg):
     CAppBase.OnConnectToServerFailed(self, t_cli, errmsg)
コード例 #19
0
 def OnStartUp(self, config_file):
     CAppBase.OnStartUp(self, config_file)
コード例 #20
0
 def OnServerDisconnect(self, t_cli):
     CAppBase.OnServerDisconnect(self, t_cli)
コード例 #21
0
 def OnClientDisconnect(self, service_type, conn_id):
     if service_type == ModTopo.SERVICE_TYPE.FOR_CLIENT:
         self.msg_manager.handle_user_logout(conn_id)
         self.del_game_server_connect(conn_id)
     CAppBase.OnClientDisconnect(self, service_type, conn_id)
コード例 #22
0
 def OnStartUp(self, confFile):
     CAppBase.OnStartUp(self, confFile)
     self.start_net_client()
コード例 #23
0
 def __init__(self):
     CAppBase.__init__(self)
     self.battle_manager = BattleManager()
     self.sec_tick_handlers = []
コード例 #24
0
 def OnShutDown(self):
     CAppBase.OnShutDown(self)
コード例 #25
0
 def __init__(self):
     CAppBase.__init__(self)
     self.scene_channel_info = {
     }  # 场景信息, server group id => channel id => server user id => scene user info
     self.scene_team_info = {
     }  # 场景队伍信息, team id => SceneTeamInfo  注: 成员列表表示在线成员
コード例 #26
0
 def __init__(self):
     CAppBase.__init__(self)
     self.user_battle_dict = {}  # 玩家战斗映射,user server id -> battle_id
     self.battle_route_dict = {}  # 战斗服务器路由字典,battle_id -> fight_node_id