Пример #1
0
def server_logout_user(cid):
    # 通知在线玩家被踢的消息
    user = g_UserMgr.getUserByCid(cid)
    if user:
        try:
            if hasattr(user, 'p') and user.p:
                user.p.send('gm_kick_connect', None)
        except Exception, e:
            log.error('exception. cid: {0}, e: {1}.'.format(cid, e))
Пример #2
0
def use_gift_code(p, req):
    ''' 使用兑换码
    @param: platform_id-合作商ID。1:tipcat, 其它...
    @param: giftcode-兑换码序列号
    @param: game_server_id-OSS中服务器管理对应的游戏服务器ID
    '''
    errorno = GIFT_CODE_FAILURE
    response, url, cid, return_code, errorno = '', '', 0, 0, 0
    platform_id, giftcode, game_server_id = int(req[0]), req[1], int(req[2])

    if platform_id is None:
        log.error('OSS PARAM ERROR. request: {0}.'.format(req))
        defer.returnValue((errorno, ''))

    # 除了tipcat外 就是heitao
    if platform_id == TIPCAT_CID:
        base_url = TIPCAT_LOCAL_OSS_URLBASE
    else:
        base_url = TIPCAT_ONLINE_OSS_URLBASE

    try:
        cid = p.cid
        url = oss_gift_code_url(base_url, platform_id, giftcode,
                                game_server_id, cid)
        #log.info('For Test. url: {0}.'.format( url ))
        gift_id = 0
        response = yield httphelper.request(url, 'POST')
        response = loads(response)
        #log.info('For Test. response: {0}.'.format( response ))
        return_code = int(response['return_code'])
        if return_code <= 0:
            log.error(
                'OSS GIFTCODE ERROR. cid: {0}, request: {1}, response: {2}, url: {3}.'
                .format(cid, req, response, url))
            errorno = OSS_RETURN_CODE.get(return_code, GIFT_CODE_FAILURE)
        else:
            gift_id = int(response['gift_id'])
            errorno = yield gs_call('new_award_to_center', (cid, gift_id))
            if errorno:
                log.error(
                    'Unknown gift_id ERROR. cid: {0}, request: {1}, response: {2}, url: {3}.'
                    .format(cid, req, response, url))

        user = g_UserMgr.getUserByCid(cid)
        if user and user.info:
            syslogger(LOG_GIFT_CODE_USE, cid, user.info['level'],
                      user.info['vip_level'], 0, giftcode, gift_id,
                      return_code, errorno)
        else:
            syslogger(LOG_GIFT_CODE_USE, cid, 0, 0, 0, giftcode, gift_id,
                      return_code, errorno)
        defer.returnValue((errorno, ''))
    except Exception as e:
        log.error('OSS GIFTCODE ERROR. cid: {0}, request: {1}, response: {2}.'.
                  format(cid, req, response))
        log.exception()
        defer.returnValue((errorno, ''))
Пример #3
0
def server_logout_user(cid):
    # 通知在线玩家被踢的消息
    user = g_UserMgr.getUserByCid( cid )
    if user:
        try:
            if hasattr(user, 'p') and user.p:
                user.p.send('gm_kick_connect', None)
        except Exception, e:
            log.error('exception. cid: {0}, e: {1}.'.format( cid, e ))
Пример #4
0
def use_gift_code(p, req):
    ''' 使用兑换码
    @param: platform_id-合作商ID。1:tipcat, 其它...
    @param: giftcode-兑换码序列号
    @param: game_server_id-OSS中服务器管理对应的游戏服务器ID
    '''
    errorno = GIFT_CODE_FAILURE
    response, url, cid, return_code, errorno = '', '', 0, 0, 0
    platform_id, giftcode, game_server_id = int(req[0]), req[1], int(req[2])

    if platform_id is None:
        log.error('OSS PARAM ERROR. request: {0}.'.format( req ))
        defer.returnValue( (errorno, '') )

    # 除了tipcat外 就是heitao
    if platform_id == TIPCAT_CID:
        base_url = TIPCAT_LOCAL_OSS_URLBASE
    else:
        base_url = TIPCAT_ONLINE_OSS_URLBASE

    try:
        cid = p.cid
        url = oss_gift_code_url(base_url, platform_id, giftcode, game_server_id, cid)
        #log.info('For Test. url: {0}.'.format( url ))
        gift_id  = 0
        response = yield httphelper.request(url, 'POST')
        response = loads(response)
        #log.info('For Test. response: {0}.'.format( response ))
        return_code = int(response['return_code'])
        if return_code <= 0:
            log.error('OSS GIFTCODE ERROR. cid: {0}, request: {1}, response: {2}, url: {3}.'.format( cid, req, response, url ))
            errorno = OSS_RETURN_CODE.get(return_code, GIFT_CODE_FAILURE)
        else:
            gift_id = int(response['gift_id'])
            errorno = yield gs_call('new_award_to_center', (cid, gift_id))
            if errorno:
                log.error('Unknown gift_id ERROR. cid: {0}, request: {1}, response: {2}, url: {3}.'.format( cid, req, response, url ))

        user = g_UserMgr.getUserByCid( cid )
        if user and user.info:
            syslogger(LOG_GIFT_CODE_USE, cid, user.info['level'], user.info['vip_level'], 0, giftcode, gift_id, return_code, errorno)
        else:
            syslogger(LOG_GIFT_CODE_USE, cid, 0, 0, 0, giftcode, gift_id, return_code, errorno)
        defer.returnValue( (errorno, '') )
    except Exception as e:
        log.error('OSS GIFTCODE ERROR. cid: {0}, request: {1}, response: {2}.'.format( cid, req, response ))
        log.exception()
        defer.returnValue( (errorno, '') )
Пример #5
0
def gm_search_character(cmd, ts, args, sign):
    res_err = {'result': 1, 'character_info': []}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        defer.returnValue(res_err)

    _infos = []
    _target_nickname = args['nick_name']
    _all_datas = yield redis.hgetall(DICT_NICKNAME_REGISTERED)
    pattern = re.compile(_target_nickname)
    for _nickname, _cid in _all_datas.iteritems():
        if not _nickname:
            continue
        if isinstance(_nickname, unicode):
            pass
        elif isinstance(_nickname, str):
            pass
        elif isinstance(_nickname, int):
            _nickname = str(_nickname)
        else:
            log.info('type: {0}.'.format(type(_nickname)))
            continue

        match = pattern.search(_nickname)
        if not match:
            continue
        #else:
        #    log.info('match.group: {0}.'.format( match.group() ))
        #log.info('For Test. _nickname: {0}, _target_nickname: {1}.'.format( _nickname, _target_nickname ))
        _level, _online = 0, 0
        user = g_UserMgr.getUserByCid(_cid)
        if user:
            _level = user.info.get('level', 0)
            _online = 1

        _infos.append({
            'character_id': _cid,
            'nick_name': _nickname,
            'level': _level,
            'online': _online
        })

    res_err['character_info'] = _infos
    defer.returnValue(res_err)
Пример #6
0
def gm_character_kick(cmd, ts, args, sign):
    """ 踢玩家下线 """
    res_err = {'result': 1}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        return res_err

    _cid = int(args['character_id'])

    user = g_UserMgr.getUserByCid(_cid)
    if not user or user.temp_lost:
        res_err['result'] = GM_CID_HAD_OFFLINE
        return res_err

    # 切断玩家的连接
    server_logout_user(_cid)
    return res_err
Пример #7
0
def gm_character_kick(cmd, ts, args, sign):
    """ 踢玩家下线 """
    res_err = {'result': 1}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        return res_err

    _cid = int(args['character_id'])

    user = g_UserMgr.getUserByCid( _cid )
    if not user or user.temp_lost:
        res_err['result'] = GM_CID_HAD_OFFLINE
        return res_err

    # 切断玩家的连接
    server_logout_user( _cid )
    return res_err
Пример #8
0
def gm_character_info(cmd, ts, args, sign):
    res_err = {'result': 1, 'character_info': {}}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        defer.returnValue(res_err)

    _cid = int(args['character_id'])

    _dict_data = {}
    user = g_UserMgr.getUserByCid(_cid)
    if user:
        _dict_data = copy.deepcopy(user.info)
        if user.temp_lost:
            _dict_data['online'] = 0
        else:
            _dict_data['online'] = 1
    else:
        try:
            errorno = yield gs_call("gs_gm_login", (_cid, True))
            if errorno:
                res_err['result'] = GM_INVALID_CID
                defer.returnValue(res_err)

            _dict_data = yield gs_call('gs_gm_get_character_info', [_cid])
            _dict_data['online'] = 0
        except Exception as e:
            log.exception()
            res_err['result'] = GM_INVALID_ERROR
            defer.returnValue(res_err)

    _dict_data['register_time'] = timestamp2string(_dict_data['register_time'])
    _dict_data['last_login_time'] = timestamp2string(
        _dict_data['last_login_time'])

    _dict_data['forbidden_seconds'] = yield check_character_status(
        _cid, TYPE_FORBIDDEN)
    _dict_data['mute_seconds'] = yield check_character_status(_cid, TYPE_MUTE)

    res_err['character_info'] = _dict_data
    defer.returnValue(res_err)
Пример #9
0
def gm_search_character(cmd, ts, args, sign):
    res_err = {'result': 1, 'character_info': []}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        defer.returnValue( res_err )

    _infos = []
    _target_nickname = args['nick_name']
    _all_datas = yield redis.hgetall(DICT_NICKNAME_REGISTERED)
    pattern = re.compile(_target_nickname)
    for _nickname, _cid in _all_datas.iteritems():
        if not _nickname:
            continue
        if isinstance(_nickname, unicode):
            pass
        elif isinstance(_nickname, str):
            pass
        elif isinstance(_nickname, int):
            _nickname = str(_nickname)
        else:
            log.info('type: {0}.'.format( type(_nickname) ))
            continue

        match = pattern.search(_nickname)
        if not match:
            continue
        #else:
        #    log.info('match.group: {0}.'.format( match.group() ))
        #log.info('For Test. _nickname: {0}, _target_nickname: {1}.'.format( _nickname, _target_nickname ))
        _level, _online = 0, 0
        user = g_UserMgr.getUserByCid( _cid )
        if user:
            _level  = user.info.get('level', 0)
            _online = 1

        _infos.append( {'character_id': _cid, 'nick_name': _nickname, 'level': _level, 'online': _online} )
    
    res_err['character_info'] = _infos
    defer.returnValue( res_err )
Пример #10
0
def gm_character_info(cmd, ts, args, sign):
    res_err = {'result': 1, 'character_info': {}}

    if len(args) != 1:
        res_err['result'] = GM_INVALID_ARGS
        defer.returnValue( res_err )

    _cid = int(args['character_id'])

    _dict_data = {}
    user = g_UserMgr.getUserByCid( _cid )
    if user:
        _dict_data = copy.deepcopy(user.info)
        if user.temp_lost:
            _dict_data['online'] = 0
        else:
            _dict_data['online'] = 1
    else:
        try:
            errorno = yield gs_call("gs_gm_login", (_cid, True))
            if errorno:
                res_err['result'] = GM_INVALID_CID
                defer.returnValue( res_err )

            _dict_data = yield gs_call('gs_gm_get_character_info', [_cid])
            _dict_data['online'] = 0
        except Exception as e:
            log.exception()
            res_err['result'] = GM_INVALID_ERROR
            defer.returnValue( res_err )

    _dict_data['register_time'] = timestamp2string( _dict_data['register_time'] )
    _dict_data['last_login_time'] = timestamp2string( _dict_data['last_login_time'] )

    _dict_data['forbidden_seconds'] = yield check_character_status(_cid, TYPE_FORBIDDEN)
    _dict_data['mute_seconds'] = yield check_character_status(_cid, TYPE_MUTE)

    res_err['character_info'] = _dict_data
    defer.returnValue( res_err )
Пример #11
0
def server_login_user(account, character_id=None):
    if character_id:
        cid = character_id
    else:
        cid = yield redis.hget(DICT_ACCOUNT_REGISTERED, account)
        if not cid:
            defer.returnValue( (GM_INVALID_CID, 0) )
        else:
            cid = int( cid )

    user = g_UserMgr.getUserByCid( cid )
    if user:
        defer.returnValue( (0, cid) )

    try:
        errorno = yield gs_call("gs_gm_login", (cid, False))
        if errorno:
            defer.returnValue( (GM_INVALID_ERROR, 0) )
    except Exception as e:
        log.warn('Some exp raise when calling gs_offline_login(). e: {0}'.format(e))
        defer.returnValue( (GM_INVALID_ERROR, 0) )

    defer.returnValue( (0, cid) )
Пример #12
0
def server_login_user(account, character_id=None):
    if character_id:
        cid = character_id
    else:
        cid = yield redis.hget(DICT_ACCOUNT_REGISTERED, account)
        if not cid:
            defer.returnValue((GM_INVALID_CID, 0))
        else:
            cid = int(cid)

    user = g_UserMgr.getUserByCid(cid)
    if user:
        defer.returnValue((0, cid))

    try:
        errorno = yield gs_call("gs_gm_login", (cid, False))
        if errorno:
            defer.returnValue((GM_INVALID_ERROR, 0))
    except Exception as e:
        log.warn(
            'Some exp raise when calling gs_offline_login(). e: {0}'.format(e))
        defer.returnValue((GM_INVALID_ERROR, 0))

    defer.returnValue((0, cid))
Пример #13
0
def payment(request):
    '''
    @param: charge_id-充值交易ID
    '''
    request.setHeader('Content-Type', 'application/json;charset=UTF-8')

    args_data_raw = request.args['args']
    #log.info("[ payment ]args raw:{0}.".format(args_data_raw))

    if 0 == len(args_data_raw):
        log.error("[ payment ]unknown args raw:{0}.".format(args_data_raw))
        defer.returnValue(json.dumps(GM_INVALID_CMD))

    cmd_info = json.loads(args_data_raw[0])

    if len(cmd_info) != 9:
        log.err("[ payment ]unknown cmd_info:{0}.".format(args_data_raw[0]))
        defer.returnValue(json.dumps(GM_INVALID_CMD))

    account, charge_id, server_id, platform_id, parent_id, currency_type, currency, t, sign = cmd_info
    log.info(
        '[ payment ]account:{0}, charge_id:{1}, platform_id:{2}, parent_id:{3}, currency_type:{4}, currency:{5}, t:{6}, sign:{7}, server_id:{8}'
        .format(account, charge_id, platform_id, parent_id, currency_type,
                currency, t, sign, server_id))

    #Check base_gm_sign later
    sign_local = base_gm_sign(*cmd_info[:-1])

    if sign != sign_local:
        log.error("[ payment ]unknown sign:{0}, correct sign:{1}.".format(
            sign, sign_local))
        defer.returnValue(json.dumps(GM_INVALID_SIGN))

    try:
        res_login = yield server_login_user('%s%s' % (account, server_id))
    except Exception as e:
        log.error("[ payment ]unknown error, e: {0}.".format(e))
        defer.returnValue(json.dumps(GM_EXECUTE_FAIL))

    err_login, cid = res_login
    if 0 != err_login:
        log.error(
            "[ payment ]unknown error. account:{0}, cid:{1}, error no:{2}.".
            format(account, cid, err_login))
        defer.returnValue(json.dumps(GM_LOGIN_USER_FAIL))

    try:
        res_data, credits_data = yield gs_call(
            "payment_from_platfrom", (cid, '', charge_id, platform_id,
                                      parent_id, currency_type, currency))

        if not res_data:
            _user = g_UserMgr.getUserByCid(cid)
            if _user:
                send2client(cid, 'sync_credits_added', credits_data[1:])
                log.info('[ payment ] credits_data: {0}.'.format(credits_data))
        else:
            log.error(
                '[ payment ]result from gameserver. res_data:{0}.'.format(
                    res_data))
            defer.returnValue(json.dumps(res_data))
    except Exception, e:
        log.exception(
            "[ payment ]gs_call error. account:{0}, charge_id:{1}, platform_id:{2}, parent_id:{3}, currency_type:{4}, currency:{5}"
            .format(account, charge_id, platform_id, parent_id, currency_type,
                    currency))
        defer.returnValue(json.dumps(GM_EXECUTE_FAIL))
Пример #14
0
def register(p, req):
    global REGISTER_ACCOUNTs
    res_err = [REGISTER_FAIL_ERROR, [None, int(time()), config.httport, 0] ]

    _account = getattr(p, 'account', None)
    if not _account:
        log.error('User no account info. from:', p.transport.getPeer())
        p.transport.loseConnection()
        defer.returnValue( res_err )

    if len(req) == 6:
        lead_id, nick_name, login_type, platform_id, version, sid = req
    else:
        lead_id, nick_name, sid = req
        login_type, platform_id, version = 0, '', ''
    
    # 判断昵称是否已被使用
    had_cid = yield redis.hget(DICT_NICKNAME_REGISTERED, nick_name)
    if had_cid:
        res_err[0] = LOGIN_REPEAT_NAME
        log.error('The nick_name had been used. had_cid: {0}, nick_name: {1}.'.format( had_cid, nick_name ))
        defer.returnValue( res_err )

    # 判断账号是否已注册
    had_cid = yield redis.hget(DICT_ACCOUNT_REGISTERED, '%s%s'%(_account,sid))
    if had_cid:
        log.warn('The account<{0}> had registered.'.format( _account ))
        res_err[0] = REGISTER_REQUEST_REPEAT
        defer.returnValue( res_err )

    # 判断是否正在注册ing
    if REGISTER_ACCOUNTs.has_key( _account ):
        log.warn('The nick_name<{0}> doing register.'.format( nick_name ))
        res_err[0] = REGISTER_REQUEST_REPEAT
        defer.returnValue( res_err )
    else:
        REGISTER_ACCOUNTs[_account] = 1

    try:
        err, char_data = yield protocol_manager.gs_call("gs_create_char", [lead_id, nick_name, _account, login_type, platform_id, version, int(sid)])
    except Exception as e:
        log.warn('gs_create_char error. e:', e)
        if REGISTER_ACCOUNTs.has_key( _account ):
            del REGISTER_ACCOUNTs[_account]
        defer.returnValue(res_err)

    if not err:
        cid  = char_data['id']
        user = g_UserMgr.getUserByCid( cid )
        if user:
            log.error('Use had existed! cid:', cid)
            if REGISTER_ACCOUNTs.has_key( _account ):
                del REGISTER_ACCOUNTs[_account]
            defer.returnValue( res_err )

        char_data['cid']     = char_data['id']
        char_data['session'] = p.session_key
        char_data['sid']     = config.server_id

        end_cd_time = yield redis.hget(HASH_SCENE_COOLDOWN_TIME, cid)
        char_data['end_cd_time'] = int( end_cd_time or 0 )

        try:
            _char_rank = 0
            try:
                alli_res, alliance_info = yield alli_call('alli_login', (cid, char_data['nick_name'], char_data['level'], char_data['vip_level'], char_data['might'], _char_rank, char_data['lead_id']))
            except:
                alli_res = 1
                log.exception()
                alliance_info = 0, '', 0

            if alli_res:
                log.error('user login allianceserver error. cid: {0}.'.format( cid ))

            result = yield ms_call('ms_login', (cid, char_data['nick_name'], char_data['lead_id'], char_data['vip_level'], char_data['level'], char_data['might'], alliance_info))
            if result:
                log.error('user login messageserver error. cid: {0}, result: {1}.'.format( cid, result ))
        except Exception as e:
            log.error('Login messageserver error. e: {0}.'.format( e ))

        g_UserMgr.loginUser(p, cid, p.session_key, _account, char_data)
 
        yield redis.hset(DICT_ACCOUNT_REGISTERED, '%s%s'%(_account,sid), char_data['cid'])
        yield redis.hset(DICT_NICKNAME_REGISTERED, nick_name, char_data['cid'])
        yield redis.sadd(SET_CID_REGISTERED, char_data['cid'])

        if REGISTER_ACCOUNTs.has_key( _account ):
            del REGISTER_ACCOUNTs[_account]
        defer.returnValue( [err, [char_data, int(time()), config.httport, 0]] )

    if REGISTER_ACCOUNTs.has_key( _account ):
        del REGISTER_ACCOUNTs[_account]
    defer.returnValue(res_err)
Пример #15
0
def register(p, req):
    global REGISTER_ACCOUNTs
    res_err = [REGISTER_FAIL_ERROR, [None, int(time()), config.httport, 0]]

    _account = getattr(p, 'account', None)
    if not _account:
        log.error('User no account info. from:', p.transport.getPeer())
        p.transport.loseConnection()
        defer.returnValue(res_err)

    if len(req) == 6:
        lead_id, nick_name, login_type, platform_id, version, sid = req
    else:
        lead_id, nick_name, sid = req
        login_type, platform_id, version = 0, '', ''

    # 判断昵称是否已被使用
    had_cid = yield redis.hget(DICT_NICKNAME_REGISTERED, nick_name)
    if had_cid:
        res_err[0] = LOGIN_REPEAT_NAME
        log.error('The nick_name had been used. had_cid: {0}, nick_name: {1}.'.
                  format(had_cid, nick_name))
        defer.returnValue(res_err)

    # 判断账号是否已注册
    had_cid = yield redis.hget(DICT_ACCOUNT_REGISTERED,
                               '%s%s' % (_account, sid))
    if had_cid:
        log.warn('The account<{0}> had registered.'.format(_account))
        res_err[0] = REGISTER_REQUEST_REPEAT
        defer.returnValue(res_err)

    # 判断是否正在注册ing
    if REGISTER_ACCOUNTs.has_key(_account):
        log.warn('The nick_name<{0}> doing register.'.format(nick_name))
        res_err[0] = REGISTER_REQUEST_REPEAT
        defer.returnValue(res_err)
    else:
        REGISTER_ACCOUNTs[_account] = 1

    try:
        err, char_data = yield protocol_manager.gs_call(
            "gs_create_char", [
                lead_id, nick_name, _account, login_type, platform_id, version,
                int(sid)
            ])
    except Exception as e:
        log.warn('gs_create_char error. e:', e)
        if REGISTER_ACCOUNTs.has_key(_account):
            del REGISTER_ACCOUNTs[_account]
        defer.returnValue(res_err)

    if not err:
        cid = char_data['id']
        user = g_UserMgr.getUserByCid(cid)
        if user:
            log.error('Use had existed! cid:', cid)
            if REGISTER_ACCOUNTs.has_key(_account):
                del REGISTER_ACCOUNTs[_account]
            defer.returnValue(res_err)

        char_data['cid'] = char_data['id']
        char_data['session'] = p.session_key
        char_data['sid'] = config.server_id

        end_cd_time = yield redis.hget(HASH_SCENE_COOLDOWN_TIME, cid)
        char_data['end_cd_time'] = int(end_cd_time or 0)

        try:
            _char_rank = 0
            try:
                alli_res, alliance_info = yield alli_call(
                    'alli_login',
                    (cid, char_data['nick_name'], char_data['level'],
                     char_data['vip_level'], char_data['might'], _char_rank,
                     char_data['lead_id']))
            except:
                alli_res = 1
                log.exception()
                alliance_info = 0, '', 0

            if alli_res:
                log.error(
                    'user login allianceserver error. cid: {0}.'.format(cid))

            result = yield ms_call(
                'ms_login', (cid, char_data['nick_name'], char_data['lead_id'],
                             char_data['vip_level'], char_data['level'],
                             char_data['might'], alliance_info))
            if result:
                log.error(
                    'user login messageserver error. cid: {0}, result: {1}.'.
                    format(cid, result))
        except Exception as e:
            log.error('Login messageserver error. e: {0}.'.format(e))

        g_UserMgr.loginUser(p, cid, p.session_key, _account, char_data)

        yield redis.hset(DICT_ACCOUNT_REGISTERED, '%s%s' % (_account, sid),
                         char_data['cid'])
        yield redis.hset(DICT_NICKNAME_REGISTERED, nick_name, char_data['cid'])
        yield redis.sadd(SET_CID_REGISTERED, char_data['cid'])

        if REGISTER_ACCOUNTs.has_key(_account):
            del REGISTER_ACCOUNTs[_account]
        defer.returnValue([err, [char_data, int(time()), config.httport, 0]])

    if REGISTER_ACCOUNTs.has_key(_account):
        del REGISTER_ACCOUNTs[_account]
    defer.returnValue(res_err)
Пример #16
0
def send2client(cid, func, args):
    _user =g_UserMgr.getUserByCid( cid )
    if _user and _user.p:
        _user.p.send(func, args)
    else:
        log.warn( 'user ({0}) not found.'.format( cid ) )
Пример #17
0
def send2client(cid, func, args):
    _user = g_UserMgr.getUserByCid(cid)
    if _user and _user.p:
        _user.p.send(func, args)
    else:
        log.warn('user ({0}) not found.'.format(cid))