Exemplo n.º 1
0
def _requestSdk2(path, params, needresponse=False):
    url = '%s%s' % (gdata.httpSdkInner(), path)
    jsonstr, _ = webpage.webget(url, postdata_=params, needresponse=needresponse)
    if needresponse:
        try:
            return strutil.loads(jsonstr)
        except:
            ftlog.error('SDKURL=', url, 'PARAMS=', params)
    return None
Exemplo n.º 2
0
 def sendSms(cls, userId, mobile, content):
     params = {'userId': userId, 'mobile': mobile, 'content': content}
     httpsdk = gdata.httpSdkInner()
     url = httpsdk + '/open/v4/user/sendSms2User'
     resp = cls._requestSdkUrl(url, params, True)
     ftlog.debug('SDKInterface.sendSms:', 'userId=', userId, 'mobile=',
                 mobile, 'content=', content, 'url=', url, 'resp=', resp)
     if resp == ErrorEnum.ERR_UNKNOWN:
         return {'code': ErrorEnum.ERR_UNKNOWN}
     return resp
Exemplo n.º 3
0
def _requestSdk2(path, params, needresponse=False):
    url = '%s%s' % (gdata.httpSdkInner(), path)
    jsonstr, _ = webpage.webget(url,
                                postdata_=params,
                                needresponse=needresponse)
    if needresponse:
        try:
            return strutil.loads(jsonstr)
        except:
            ftlog.error('SDKURL=', url, 'PARAMS=', params)
    return None
Exemplo n.º 4
0
def getOrderIdHttpCallBack(orderId):
    # 取得单号对应的callback地址, 如果没有Name意味就是本机线上服务单号
    httpcallback = daobase.executeMixCmd('HGET', 'global.orderid.callback', orderId)
    if httpcallback != None and isinstance(httpcallback, (str, unicode)) and httpcallback.find('http://') == 0:
        nsize = daobase.executeMixCmd('HLEN', 'global.orderid.callback')
        if nsize > 10000:
            daobase.executeMixCmd('DEL', 'global.orderid.callback')
            ftlog.error('the test order "global.orderid.callback" too much (> 10000) !! ' +
                        'auto clean up !! some test order maybe callback to online !' +
                        'this is not an error, just a warring !!')
        return httpcallback
    return gdata.httpSdkInner()
Exemplo n.º 5
0
def getOrderIdHttpCallBack(orderId):
    # 取得单号对应的callback地址, 如果没有Name意味就是本机线上服务单号
    httpcallback = daobase.executeMixCmd('HGET', 'global.orderid.callback',
                                         orderId)
    if httpcallback != None and isinstance(
            httpcallback,
        (str, unicode)) and httpcallback.find('http://') == 0:
        nsize = daobase.executeMixCmd('HLEN', 'global.orderid.callback')
        if nsize > 10000:
            daobase.executeMixCmd('DEL', 'global.orderid.callback')
            ftlog.error(
                'the test order "global.orderid.callback" too much (> 10000) !! '
                +
                'auto clean up !! some test order maybe callback to online !' +
                'this is not an error, just a warring !!')
        return httpcallback
    return gdata.httpSdkInner()
Exemplo n.º 6
0
    def _doLogin(self):
        loginur = gdata.httpSdkInner() + '/open/v3/user/processSnsId'
        params = {'svninfo': '$robot$',
                  'appId': str(self.gameId),
                  'ty_bindmobile': '',
                  'phoneType': '',
                  'imei': ['Xb6tiNAVcw5eLrd1F4JTW2dnDrGNr3P0EXl2x99NUeVYGHCQB6ECeQ=='],
                  'iccid': ['RcjQJPkcLGfazgYaKJGWd8hTMfWp8OVr86NEoHuo1C0fIaCKUsTAhuB7huInoqWf'],
                  'androidId': ['BwyJv/PH1UCPjZDob4BSPgiwpuTq4dYgt1OFMrAoLJTED4oxlxdnEtuXKiOJxpkV'],
                  'snsToken': '',
                  'mac': ['wn+rGmlh6/AG6S6O+7kew0ZaMHsfR0LstUtr/WOvXtX681nrM5c+406L0PvY3P7W'],
                  'ty_uid': '0',
                  'clientId': self.clientId,
                  'deviceName': self.name,
                  'snsId': strutil.tyDesEncode(self.snsId),
                  'deviceId': ''
                  }
        sigstr = ''
        pkeys = params.keys()
        pkeys.sort()
        for k in pkeys:
            sigstr = sigstr + str(k) + '=' + str(params[k]) + '&'
        sigstr = sigstr[:-1]
        code = strutil.md5digest(strutil.tyDesEncode(sigstr))
        params['code'] = code

        userInfo, _ = webpage.webget(loginur, params)
        userInfo = strutil.loads(userInfo, ignoreException=True, execptionValue=userInfo)
        if not isinstance(userInfo, dict):
            ftlog.warn('snsId=', self.snsId, 'login-> return error !', userInfo)
            self.stop()
            return
        if self.isbusy == 0:  # 已经关闭
            return

        ftlog.debug('snsId=', self.snsId, 'login->', userInfo)

        result = userInfo.get('result', {})
        self.userId = result.get('userId', 0)
        if not isinstance(self.userId, int) or self.userId < 0:
            raise Exception('robot user login false !' + self.snsId)
        ftlog.debug('Robot login ok snsId=', self.snsId, 'userId=', self.userId)
        self.userInfo = result
        self.checkState(CMD_LOGIN)
Exemplo n.º 7
0
def _reportOnlineToSdk(_lockobj):
    '''
    向当前的SDK服务汇报自己的运行状态
    '''
    posturl = '%s/_game_server_online_?' % (gdata.httpSdkInner())
    datas = {'http_game': gdata.httpGame(),
             'conns': gdata.getUserConnIpPortList(),
             'mode': gdata.mode(),
             'name': gdata.name(),
             'time': int(time.time())
             }
    datas = strutil.dumpsbase64(datas)
    ret, _ = webpage.webgetJson(posturl, {'params': datas}, None, 10)
    if isinstance(ret, dict):
        result = ret.get('result', {})
        ok = result.get('ok', False)
        if ok == True:
            global _REPORT_OK
            _REPORT_OK = True
            ftlog.debug('_reportOnlineToSdk-> OK !', ret)
            return
    ftlog.debug('_reportOnlineToSdk-> ERROR !', ret)
Exemplo n.º 8
0
def _reportOnlineToSdk(_lockobj):
    '''
    向当前的SDK服务汇报自己的运行状态
    '''
    posturl = '%s/_game_server_online_?' % (gdata.httpSdkInner())
    datas = {
        'http_game': gdata.httpGame(),
        'conns': gdata.getUserConnIpPortList(),
        'mode': gdata.mode(),
        'name': gdata.name(),
        'time': int(time.time())
    }
    datas = strutil.dumpsbase64(datas)
    ret, _ = webpage.webgetJson(posturl, {'params': datas}, None, 10)
    if isinstance(ret, dict):
        result = ret.get('result', {})
        ok = result.get('ok', False)
        if ok == True:
            global _REPORT_OK
            _REPORT_OK = True
            ftlog.debug('_reportOnlineToSdk-> OK !', ret)
            return
    ftlog.debug('_reportOnlineToSdk-> ERROR !', ret)
Exemplo n.º 9
0
    def _doLogin(self):
        loginur = gdata.httpSdkInner() + '/open/v3/user/processSnsId'
        params = {
            'svninfo':
            '$robot$',
            'appId':
            str(self.gameId),
            'ty_bindmobile':
            '',
            'phoneType':
            '',
            'imei':
            ['Xb6tiNAVcw5eLrd1F4JTW2dnDrGNr3P0EXl2x99NUeVYGHCQB6ECeQ=='],
            'iccid': [
                'RcjQJPkcLGfazgYaKJGWd8hTMfWp8OVr86NEoHuo1C0fIaCKUsTAhuB7huInoqWf'
            ],
            'androidId': [
                'BwyJv/PH1UCPjZDob4BSPgiwpuTq4dYgt1OFMrAoLJTED4oxlxdnEtuXKiOJxpkV'
            ],
            'snsToken':
            '',
            'mac': [
                'wn+rGmlh6/AG6S6O+7kew0ZaMHsfR0LstUtr/WOvXtX681nrM5c+406L0PvY3P7W'
            ],
            'ty_uid':
            '0',
            'clientId':
            self.clientId,
            'deviceName':
            self.name,
            'snsId':
            strutil.tyDesEncode(self.snsId),
            'deviceId':
            ''
        }
        sigstr = ''
        pkeys = params.keys()
        pkeys.sort()
        for k in pkeys:
            sigstr = sigstr + str(k) + '=' + str(params[k]) + '&'
        sigstr = sigstr[:-1]
        code = strutil.md5digest(strutil.tyDesEncode(sigstr))
        params['code'] = code

        userInfo, _ = webpage.webget(loginur, params)
        userInfo = strutil.loads(userInfo,
                                 ignoreException=True,
                                 execptionValue=userInfo)
        if not isinstance(userInfo, dict):
            ftlog.warn('snsId=', self.snsId, 'login-> return error !',
                       userInfo)
            self.stop()
            return
        if self.isbusy == 0:  # 已经关闭
            return

        ftlog.debug('snsId=', self.snsId, 'login->', userInfo)

        result = userInfo.get('result', {})
        self.userId = result.get('userId', 0)
        if not isinstance(self.userId, int) or self.userId < 0:
            raise Exception('robot user login false !' + self.snsId)
        ftlog.debug('Robot login ok snsId=', self.snsId, 'userId=',
                    self.userId)
        self.userInfo = result
        self.checkState(CMD_LOGIN)