Beispiel #1
0
def server_login_2(command_id, dynamic_id, request_proto):
    """ 帐号登录
    @param command_id:
    @param dynamic_id:
    @param request_proto:
    @return:
    """

    # 登录数据解析
    account_request = account_pb2.AccountLoginRequest()
    account_request.ParseFromString(request_proto)
    key = account_request.passport

    account_response = account_pb2.AccountResponse()
    account_response.result = False

    # 通知帐号服
    logger.info('rpc account verify:%s', key)
    result = GlobalObject().remote['login'].account_verify_remote(key)
    result = eval(result)
    logger.info('verify result:%s', result)
    if result.get('result') is True:  # 登录成功
        uuid = result.get('uuid')
        logger.info('login uuid:%s', uuid)
        account_id = get_account_id(uuid)
        # print account_id
        if account_id == 0:
            account_response.result = False
            account_response.message = '2'
        else:
            account_response.result = __manage_user(uuid, account_id,
                                                    dynamic_id)
    logger.debug(account_response)
    return account_response.SerializeToString()
Beispiel #2
0
def server_login_2(command_id, dynamic_id, request_proto):
    """ 帐号登录
    @param command_id:
    @param dynamic_id:
    @param request_proto:
    @return:
    """

    # 登录数据解析
    account_request = account_pb2.AccountLoginRequest()
    account_request.ParseFromString(request_proto)
    key = account_request.passport

    account_response = account_pb2.AccountResponse()
    account_response.result = False

    # 通知帐号服
    logger.info('rpc account verify:%s', key)
    result = GlobalObject().remote['login'].account_verify_remote(key)
    result = eval(result)
    logger.info('verify result:%s', result)
    if result.get('result') is True:  # 登录成功
        uuid = result.get('uuid')
        logger.info('login uuid:%s', uuid)
        account_id = get_account_id(uuid)
        # print account_id
        if account_id == 0:
            account_response.result = False
            account_response.message = '2'
        else:
            account_response.result = __manage_user(uuid,
                                                    account_id,
                                                    dynamic_id)
    logger.debug(account_response)
    return account_response.SerializeToString()
Beispiel #3
0
def _doChildConnect(name, transport):
    """当server节点连接到master的处理
    """
    # 当前启动的server 的配置
    server_config = GlobalObject().json_config.get('servers', {}).get(name, {})
    remoteport = server_config.get('remoteport', [])
    child_host = transport.transport.address[0]
    root_list = [rootport.get('rootname') for rootport in remoteport]
    GlobalObject().remote_map[name] = {
        "host": child_host,
        "root_list": root_list
    }
    # 通知有需要连的node节点连接到此root节点
    for servername, remote_list in GlobalObject().remote_map.items():
        remote_host = remote_list.get("host", "")
        remote_name_host = remote_list.get("root_list", "")
        if name in remote_name_host:
            child_name = GlobalObject().root.childsmanager.child(servername)
            child_name.callbackChild("remote_connect", name, remote_host)
    # 查看当前是否有可供连接的root节点
    master_node_list = GlobalObject().remote_map.keys()
    for root_name in root_list:
        if root_name in master_node_list:
            root_host = GlobalObject().remote_map[root_name]['host']
            child_name = GlobalObject().root.childsmanager.child(name)
            child_name.callbackChild("remote_connect", root_name, root_host)
Beispiel #4
0
def _doChildConnect(name,transport):
    """当server节点连接到master的处理
    """
    server_config = GlobalObject().json_config.get('servers',{}).get(name,{})
    remoteport = server_config.get('remoteport',[])
    child_host = transport.transport.address[0]
    root_list = [rootport.get('rootname') for rootport in remoteport]
    GlobalObject().remote_map[name] = {"host":child_host,"root_list":root_list}
    #通知有需要连的node节点连接到此root节点
    for servername,remote_list in GlobalObject().remote_map.items():
        remote_host = remote_list.get("host","")
        remote_name_host = remote_list.get("root_list","")
        if name in remote_name_host:
            GlobalObject().root.callChild(servername,"remote_connect",name,remote_host)
    #查看当前是否有可供连接的root节点
    master_node_list = GlobalObject().remote_map.keys()
    for root_name in root_list:
        if root_name in master_node_list:
            root_host = GlobalObject().remote_map[root_name]['host']
            GlobalObject().root.callChild(name,"remote_connect",root_name,root_host)