def sendNotify_message(gameId, userId, argd): results = {} results['pic'] = argd['iconAddr'] results['des'] = argd['context'] results['buttonType'] = argd['buttonType'] if argd['buttonType'] in ( '1', '2') else '1' results['todo'] = argd['passthrough'] results['closeTime'] = argd['timelimit'] results['alarmime'] = '0' results['action'] = 'notify_message' results['hideIcon'] = argd.get('hideIcon', '0') if len(argd['passthrough']) > 5: todoTask = eval(argd['passthrough']) results['todo'] = todoTask ftlog.hinfo('notify sendNotify_message passthrough todoTask', gameId, userId, todoTask, type(todoTask), argd['passthrough']) mp = MsgPack() mp.setCmd('game_notice') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.hinfo('notify sendNotify_message', gameId, userId, results)
def doGetLiveShowTableList(self, userId, clientId): '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态 ''' msgRes = MsgPack() msgRes.setCmd("game") msgRes.setResult("action", "live_show_table_list") msgRes.updateResult(self._getVipTableList(userId, clientId, tag="", isLiveShowRoom=True)) router.sendToUser(msgRes, userId)
def doGetMasterTableList(self, userId, clientId): '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态 ''' msgRes = MsgPack() msgRes.setCmd("game") msgRes.setResult("action", "master_table_list") msgRes.updateResult( self._getVipTableList(userId, clientId, tag="", isMasterRoom=True)) router.sendToUser(msgRes, userId)
def sendVipClientId2client(gameId, userId, keyId): results = {} results['vip_clientId'] = keyId mp = MsgPack() mp.setCmd('game_vipclientId') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.info("localservice|sendVipClientId2client|", gameId, userId, keyId)
def doRoomGetPlayingTableList(self, roomId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) result = gdata.rooms()[roomId].doGetPlayingTableList() if router.isQuery() : mo = MsgPack() mo.setCmd("room") mo.setResult("action", "playingTableList") mo.updateResult(result) router.responseQurery(mo)
def doRoomGetPlayingTableList(self, roomId): msg = runcmd.getMsgPack() ftlog.debug('msg=', msg, caller=self) result = gdata.rooms()[roomId].doGetPlayingTableList() if router.isQuery(): mo = MsgPack() mo.setCmd("room") mo.setResult("action", "playingTableList") mo.updateResult(result) router.responseQurery(mo)
def getShareDownloadUrl(gameId, userId, source): clientId = sessiondata.getClientId(userId) ok, clientOs, cid, special, mc, sc = parseClientIdForDL(clientId) if not ok: ftlog.warn("getShareDownloadUrl|parseClientId|error", gameId, userId, source, cid, special, mc, sc) return channels = configure.getGameJson(HALL_GAMEID, "download").get("channels", {}) channel = clientOs + '.' + special + '.' + mc + '.' + sc downloadurl = channels['default'] if channel in channels: downloadurl = channels[channel] mix_domain = [ "dspkm.cc", "lkxjv.cc", "qkpwdfo.cc", "sijas.cc", "023i.cc", "lkjsdf.cc", "vdlskm.cc", "iojpdvs.cc", "sdvnkl.cc", "owirhj.cc", "lvsdp.cc", "msvdkn.cc", "dvslkm.cc", "odnsvk.cc", "p0joefipq.cc", "mvsdpok.cc", "02r389u.cc", "sdlknv.cc", "sdfioj.cc", "klsdvm.cc" ] domainList = configure.getGameJson(HALL_GAMEID, "misc").get("mix_domain", mix_domain) replaceDict = { 'mc': mc, 'sc': sc, 'cid': str(cid), 'uid': userId, 'mixDomain': genMixDomain(domainList) } downloadurl = strutil.replaceParams(downloadurl, replaceDict) parsedUrl = urlparse.urlparse(downloadurl) qparams = urlparse.parse_qs(parsedUrl.query) if parsedUrl.query else {} qparams = {k: v[0] for k, v in qparams.iteritems()} qparams.update({'source': source}) results = {} results['action'] = 'geturl' results['downloadurl'] = urlparse.urlunparse( (parsedUrl[0], parsedUrl[1], parsedUrl[2], parsedUrl[3], urllib.urlencode(qparams), parsedUrl[5])) from freetime.entity.msg import MsgPack from poker.protocol import router mp = MsgPack() mp.setCmd('share_hall') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) if ftlog.is_debug(): ftlog.debug("getShareDownloadUrl|", gameId, userId, results)
def sendCheckinId2client(gameId, userId, checkinId): results = {} results['clientId'] = checkinId mp = MsgPack() mp.setCmd('game_clientId') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.info("localservice|sendCheckinId2client|", gameId, userId, checkinId)
def doActivity5ExchangeItemList(self, gameId, userId, clientId): msg = runcmd.getMsgPack() ftlog.debug('doActivity5ExchangeItemList msg=', msg) exchangeList = _doActivity5ExchangeItemList(gameId, userId, clientId) mo = MsgPack() mo.setCmd('act') mo.setResult("gameId", gameId) mo.setResult("userId", userId) mo.setResult("action", "exchange_item_list") mo.updateResult(exchangeList) ftlog.debug("doActivity5ExchangeItemList, mo=", mo) router.sendToUser(mo, userId)
def doTableManage(self, roomId, tableId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] action = msg.getParam('action') result = table.doTableManage(msg, action) if router.isQuery(): mo = MsgPack() mo.setCmd('table_manage') mo.setResult('action', action) mo.updateResult(result) router.responseQurery(mo)
def doTableManage(self, roomId, tableId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] action = msg.getParam('action') result = table.doTableManage(msg, action) if router.isQuery() : mo = MsgPack() mo.setCmd('table_manage') mo.setResult('action', action) mo.updateResult(result) router.responseQurery(mo)
def sendNotify_announce(gameId, userId, argd): results = {} results['context'] = argd['context'] results['action'] = 'notify_announce' mp = MsgPack() mp.setCmd('game_notice') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.hinfo('notify sendNotify_announce', gameId, userId, results)
def sendPriceList2client(gameId, userId, clientId, pricelist): results = {} results['pricelist'] = pricelist mp = MsgPack() mp.setCmd('game_pricelist') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.debug("localservice|sendPriceList2client|", gameId, userId, clientId, pricelist)
def sendConfigData2client(gameId, userId, action, configData): results = {} results['action'] = action results['configData'] = configData mp = MsgPack() mp.setCmd('game_config') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.info("localservice|sendConfigJson2client|", gameId, userId, action, configData)
def sendMsg2client(gameId, userId, action, params): results = {} results.update(params) # results['params'] = params results['action'] = action mp = MsgPack() mp.setCmd('game_popwinodws') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.debug("npw_|sendmsg2client|", gameId, userId, action, results)
def doHelloTuyou(self): gameId = runhttp.getParamInt('gameId') clientId = runhttp.getParamStr('clientId', '') ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId) mo = MsgPack() mo.setCmd('hello') if gameId not in gdata.gameIds(): mo.setError(1, 'gameId error !') ftlog.error('doHelloTuyou gameId error', runhttp.getDict()) return mo try: clientIdInt = pokerconf.clientIdToNumber(clientId) except: clientIdInt = 0 ftlog.error() if clientIdInt <= 0: mo.setError(2, 'clientId error !') ftlog.error('doHelloTuyou clientId error', runhttp.getDict()) return mo nicaiCode = runhttp.getParamStr('nicaiCode', '') if not nicaiCode: mo.setError(3, 'nicai error !') ftlog.error('doHelloTuyou nicai error', runhttp.getDict()) return mo # 1. 生存你猜CODE HelloTuyou.getNiCaiCode(mo, nicaiCode) # 2. 取得更新信息 updateVersion = runhttp.getParamInt('updateVersion') alphaVersion = runhttp.getParamInt('alphaVersion', 0) HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion) # 3. 静态配置文件的MD5和URL staticConf = hallconf.getUpgradeStaticConf() mo.updateResult(staticConf) # 4. 返回三方SDK的控制开关 HelloTuyou.getThirdSwitches(mo, clientId) # 设置其他返回值 mo.setResult('gameId', gameId) mo.setResult('clientId', clientId) return mo
def doTableManage(self, roomId, tableId): msg = runcmd.getMsgPack() room = gdata.rooms()[roomId] table = room.maptable[tableId] action = msg.getParam('action') if isinstance(table, DizhuTableCtrl): table.proto.handleMsg(msg) else: table = room.maptable[tableId] result = table.doTableManage(msg, action) if router.isQuery(): mo = MsgPack() mo.setCmd('table_manage') mo.setResult('action', action) mo.updateResult(result) router.responseQurery(mo)
def getShareDownloadUrl(gameId, userId, source): clientId = sessiondata.getClientId(userId) ok, clientOs, cid, special, mc, sc = parseClientIdForDL(clientId) if not ok: ftlog.hinfo("getShareDownloadUrl|parseClientId|error", gameId, userId, source, cid, special, mc, sc) return channels = configure.getGameJson(HALL_GAMEID, "download").get("channels", {}) channel = clientOs + "." + special + "." + mc + "." + sc download = channels["default"] if channel in channels: download = channels[channel] mix_domain = [ "dspkm.cc", "lkxjv.cc", "qkpwdfo.cc", "sijas.cc", "023i.cc", "lkjsdf.cc", "vdlskm.cc", "iojpdvs.cc", "sdvnkl.cc", "owirhj.cc", "lvsdp.cc", "msvdkn.cc", "dvslkm.cc", "odnsvk.cc", "p0joefipq.cc", "mvsdpok.cc", "02r389u.cc", "sdlknv.cc", "sdfioj.cc", "klsdvm.cc" ] domainList = configure.getGameJson(HALL_GAMEID, "misc").get("mix_domain", mix_domain) downloadurl = "http://" + HallShare.randomUrlPrefix( ) + "." + random.choice( domainList ) + download + "?" + "mc=" + mc + "&" + "sc=" + sc + "&" + "cid=" + str( cid) + "&" + "source=" + source results = {} results["action"] = "geturl" results["downloadurl"] = downloadurl from freetime.entity.msg import MsgPack from poker.protocol import router mp = MsgPack() mp.setCmd("share_hall") mp.setResult("gameId", gameId) mp.setResult("userId", userId) mp.updateResult(results) router.sendToUser(mp, userId) if ftlog.is_debug(): ftlog.debug("getShareDownloadUrl|", gameId, userId, results)
def getMyFriendTableRecord(self, userId, gameId): """获取我的好友桌战绩 """ records = gamedata.getGameAttr(userId, DIZHU_GAMEID, "friendTableRecords") ftlog.debug("getMyFriendTableRecord userId =", userId, "records =", records) if records: records = json.loads(records) else: records = [] msgRes = MsgPack() msgRes.setCmd("dizhu") msgRes.setResult('gameId', gameId) msgRes.updateResult({"action": "get_ft_table_record"}) msgRes.setResult("records", records) router.sendToUser(msgRes, userId)
def doGetVipTableList(self, userId, clientId): '''为了效率,贵宾室所有桌子放在一个GT进程里, 在此进程中通过遍历来获取每张桌子的状态 ''' msgRes = MsgPack() msgRes.setCmd("game") msgRes.setResult("action", "vip_table_list") clientVer = sessiondata.getClientIdVer(userId) if clientVer < 5.0: if self.gameId == 8: msgRes.setCmd("texas_room_list_response") if self.gameId == 30: msgRes.setCmd("room") msgRes.setResult("action", "vipTableList") msg = FTTasklet.getCurrentFTTasklet().pack tag = msg.getParam("tag", "") msgRes.updateResult(self._getVipTableList(userId, clientId, tag)) router.sendToUser(msgRes, userId)
def doHelloTuyou(self): gameId = runhttp.getParamInt('gameId') clientId = runhttp.getParamStr('clientId', '') ftlog.debug('Hello->gameId=', gameId, 'clientId=', clientId) mo = MsgPack() mo.setCmd('hello') if gameId not in gdata.gameIds(): mo.setError(1, 'gameId error !') return mo clientIdInt = pokerconf.clientIdToNumber(clientId) if clientIdInt <= 0: mo.setError(2, 'clientId error !') return mo nicaiCode = runhttp.getParamStr('nicaiCode', '') if not nicaiCode: mo.setError(3, 'nicai error !') return mo # 1. 生存你猜CODE HelloTuyou.getNiCaiCode(mo, nicaiCode) # 2. 取得更新信息 updateVersion = runhttp.getParamInt('updateVersion') alphaVersion = runhttp.getParamInt('alphaVersion', 0) HelloTuyou.getUpdataInfo(mo, gameId, clientId, updateVersion, alphaVersion) # 3. 静态配置文件的MD5和URL staticConf = hallconf.getUpgradeStaticConf() mo.updateResult(staticConf) # 4. 返回三方SDK的控制开关 HelloTuyou.getThirdSwitches(mo, clientId) # 设置其他返回值 mo.setResult('gameId', gameId) mo.setResult('clientId', clientId) return mo
def sendMsg2client(gameId, userId, type, context, isDisplay=True, npwId='', where=WHERE_REQ): if isDisplay == False: ftlog.hinfo("newcheckin|sendmsg2client|isDisplay", gameId, userId, type, context, where) return results = {} results['type'] = type # '3','7' results['context'] = context mp = MsgPack() if where == WHERE_NPW: mp.setCmd('game_popwinodws') results['action'] = 'newpop_checkin' results['npwId'] = npwId else: mp.setCmd('new_checkin') mp.setResult('gameId', gameId) mp.setResult('userId', userId) mp.updateResult(results) router.sendToUser(mp, userId) ftlog.debug("newcheckin|sendmsg2client|", gameId, userId, type, context, where, results)
def getCustomRecords(self, gameId, msg): '''获取战绩 ''' if ftlog.is_debug(): ftlog.debug("<< |msg", msg, caller=self) userId = msg.getParam("userId") records = gamedata.getGameAttr(userId, gameId, "customTableRecords") if records: records = json.loads(records) else: records = [] for record_item in records: if not record_item.get("totalPlayNum"): record_item['totalPlayNum'] = "-" msgRes = MsgPack() msgRes.setCmd("game") msgRes.updateResult({"action": "get_custom_records"}) msgRes.setResult("records", records) router.sendToUser(msgRes, userId)
def makeStaticMessage(): staticConf = hallconf.getUpgradeStaticConf() mo = MsgPack() mo.setCmd('local_static') mo.updateResult(staticConf) return mo