Ejemplo n.º 1
0
 def send_msg_to_server_node(self, client_type, msg_str, *args):
     # scene的服务器节点: monitor、scene proxy、db
     logger.GetLog().debug('send_msg_to_server_node : %s, %s' %
                           (client_type, args))
     server_node_type = self.get_node_type_by_client_type(client_type)
     if server_node_type in self.connect_server_dict and self.connect_server_dict[
             server_node_type]:
         if server_node_type == ModTopo.NODE_TYPE.MONITOR:
             game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.COMMON,
                                  msg_str)
         elif server_node_type == ModTopo.NODE_TYPE.SCENE_PROXY:
             if client_type == server_node_type:
                 # 需要查找一个实际的node
                 client_type = self.connect_server_dict[
                     server_node_type].keys()[0]  # 因为proxy只有1个, 所以直接取
             game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.SCENE,
                                  msg_str)
         elif server_node_type == ModTopo.NODE_TYPE.DB_PROXY:
             if client_type == server_node_type:
                 # 随机一个db节点处理即可
                 client_type = random.choice(
                     self.connect_server_dict[server_node_type].keys())
             game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.SCENE,
                                  msg_str)
         else:
             logger.GetLog().error(
                 'send msg to an unsupported server node : %s, %s, %s' %
                 (client_type, msg_str, args))
     else:
         logger.GetLog().error(
             'send msg to server node %s but there is no one in connect_server_dict'
             % server_node_type)
Ejemplo n.º 2
0
 def send_msg_to_server_node(self, client_type, msg_str, *args):
     # fight proxy的服务器节点: monitor、gateway
     server_node_type = self.get_node_type_by_client_type(client_type)
     if server_node_type == ModTopo.NODE_TYPE.MONITOR:
         game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.COMMON, msg_str)
     elif server_node_type == ModTopo.NODE_TYPE.GATEWAY:
         if server_node_type in self.connect_server_dict:
             if client_type == server_node_type:
                 # 广播给所有的gateway
                 for real_client_type in self.connect_server_dict[server_node_type].keys():
                     game.SendMsgToServer(real_client_type, ModTopo.PROTO_TYPE.FIGHT, msg_str)
             else:
                 game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.FIGHT, msg_str)
         else:
             logger.GetLog().warn('no gateway connect')
     else:
         logger.GetLog().error('send msg to an unexpected server node : %s, %s, %s' % (client_type, msg_str, args))
Ejemplo n.º 3
0
 def send_msg_to_server_node(self, client_type, msg_str, *args):
     # gateway的服务器节点: monitor
     server_node_id = self.get_node_type_by_client_type(client_type)
     if server_node_id == ModTopo.NODE_TYPE.MONITOR:
         game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.COMMON,
                              msg_str)
     else:
         logger.GetLog().error(
             'send msg to an unexpected server node : %s, %s, %s' %
             (client_type, msg_str, args))
Ejemplo n.º 4
0
 def send_msg_to_server_node(self, client_type, msg_str, *args):
     # db的服务器节点: monitor
     server_node_type = self.get_node_type_by_client_type(client_type)
     if server_node_type in self.connect_server_dict and self.connect_server_dict[
             server_node_type]:
         if server_node_type == ModTopo.NODE_TYPE.MONITOR:
             game.SendMsgToServer(client_type, ModTopo.PROTO_TYPE.COMMON,
                                  msg_str)
         else:
             logger.GetLog().error(
                 'send msg to an unsupported server node : %s, %s, %s' %
                 (client_type, msg_str, args))
     else:
         logger.GetLog().error(
             'send msg to server node %s but there is no one in connect_server_dict'
             % server_node_type)
Ejemplo n.º 5
0
 def SendMsg(self, msg, proto):
     game.SendMsgToServer(ModTopo.NODE_TYPE.GATEWAY, proto,
                          msgpack.packb(msg))