def _initialize(): ''' 初始化命令路由 ''' ftlog.debug('router._initialize begin') allsrv = gdata.serverTypeMap() pass
def sendToAll(msgpack, serverType='', head2=''): if isinstance(msgpack, MsgPack): msgpack = msgpack.pack() assert (isinstance(msgpack, basestring)) for stype, sids in gdata.serverTypeMap().items(): if not serverType or serverType == stype: for dst in sids: wrapper.send(dst, msgpack, 'S7', head2)
def sendToAll(msgpack, serverType='', head2=''): if isinstance(msgpack, MsgPack): msgpack = msgpack.pack() assert (isinstance(msgpack, basestring)) for stype, sids in gdata.serverTypeMap().items(): if not serverType or serverType == stype: for dst in sids: wrapper.send(dst, msgpack, 'S7', head2)
def _doReportStatus(event): global _REPORT_OK if (event.count % 600 == 1 or _REPORT_OK == 0) \ and gdata.isControlProcess() \ and len(gdata.serverTypeMap().get(gdata.SRV_TYPE_HTTP, [])) > 0: ''' 每10分钟, 汇报一次, 服务在线, 且 只有当控制进程时才汇报, 否者视为非游戏大厅服务 只需要第一个进程进行汇报即可 ''' try: _reportOnlineToSdk(_lockobj) except: ftlog.error()
def _doReportStatus(event): global _REPORT_OK if (event.count % 600 == 1 or _REPORT_OK == 0) \ and gdata.isControlProcess() \ and len(gdata.serverTypeMap().get(gdata.SRV_TYPE_HTTP, [])) > 0: ''' 每10分钟, 汇报一次, 服务在线, 且 只有当控制进程时才汇报, 否者视为非游戏大厅服务 只需要第一个进程进行汇报即可 ''' try: _reportOnlineToSdk(_lockobj) except: ftlog.error()
def _initialize(): ''' 初始化命令路由 ''' ftlog.debug('router._initialize begin') allsrv = gdata.serverTypeMap() global _connServer _connServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_CONN, None), gdata.SRV_TYPE_CONN) global _utilServer _utilServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_UTIL, None), gdata.SRV_TYPE_UTIL) global _httpServer _httpServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_HTTP, None), gdata.SRV_TYPE_HTTP) global _robotServer _robotServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_ROBOT, None), gdata.SRV_TYPE_ROBOT) global _centerServer _centerServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_CENTER, None), gdata.SRV_TYPE_CENTER) global _agentServer _agentServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_AGENT, None), gdata.SRV_TYPE_AGENT) global _sdkHttpServer _sdkHttpServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_SDK_HTTP, None), gdata.SRV_TYPE_SDK_HTTP) global _gatewayHttpServer _gatewayHttpServer = _RouterServer( allsrv.get(gdata.SRV_TYPE_SDK_GATEWAY, None), gdata.SRV_TYPE_SDK_GATEWAY) # 整理CONN接入使用的命令路由表 for srvtype, cmds in pokerconf.getCmds().items(): if srvtype == 'NOT_USED': global _cmd_notuse_map _cmd_notuse_map = set(cmds.keys()) ftlog.debug('NOT_USED CMD->', _cmd_notuse_map) elif srvtype == 'GROUP_MATCH': global _cmd_group_match_set _cmd_group_match_set = set(cmds) ftlog.debug('GROUP_MATCH CMD->', _cmd_group_match_set) else: assert (srvtype in gdata.SRV_TYPE_ALL) for cmd in cmds: assert (cmd not in _cmd_route_map) _cmd_route_map[cmd] = cmds[cmd] cmds[cmd]['target'] = srvtype ftlog.debug('router._cmd_route_map=', _cmd_route_map) ftlog.debug('router._initialize end')
def _initialize(): ''' 初始化命令路由 ''' ftlog.debug('router._initialize begin') allsrv = gdata.serverTypeMap() global _connServer _connServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_CONN, None), gdata.SRV_TYPE_CONN) global _utilServer _utilServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_UTIL, None), gdata.SRV_TYPE_UTIL) global _httpServer _httpServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_HTTP, None), gdata.SRV_TYPE_HTTP) global _robotServer _robotServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_ROBOT, None), gdata.SRV_TYPE_ROBOT) global _centerServer _centerServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_CENTER, None), gdata.SRV_TYPE_CENTER) global _agentServer _agentServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_AGENT, None), gdata.SRV_TYPE_AGENT) global _sdkHttpServer _sdkHttpServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_SDK_HTTP, None), gdata.SRV_TYPE_SDK_HTTP) global _gatewayHttpServer _gatewayHttpServer = _RouterServer(allsrv.get(gdata.SRV_TYPE_SDK_GATEWAY, None), gdata.SRV_TYPE_SDK_GATEWAY) # 整理CONN接入使用的命令路由表 for srvtype, cmds in pokerconf.getCmds().items(): if srvtype == 'NOT_USED': global _cmd_notuse_map _cmd_notuse_map = set(cmds.keys()) ftlog.debug('NOT_USED CMD->', _cmd_notuse_map) elif srvtype == 'GROUP_MATCH': global _cmd_group_match_set _cmd_group_match_set = set(cmds) ftlog.debug('GROUP_MATCH CMD->', _cmd_group_match_set) else: assert (srvtype in gdata.SRV_TYPE_ALL) for cmd in cmds: assert (cmd not in _cmd_route_map) _cmd_route_map[cmd] = cmds[cmd] cmds[cmd]['target'] = srvtype ftlog.debug('router._cmd_route_map=', _cmd_route_map) ftlog.debug('router._initialize end')
def _initialize(): return # 当前没有做数据缓存,无需数据变化通知 if gdata.serverType() != gdata.SRV_TYPE_UTIL: return channelcount = 16 channels = [] usids = gdata.serverTypeMap()[gdata.SRV_TYPE_UTIL] usids.sort() if len(usids) < channelcount: if usids[0] == gdata.serverId(): for x in xrange(channelcount): channels.append('userdatachange_%d' % (x)) else: if gdata.serverId() in usids: i = usids.index(gdata.serverId()) if i < channelcount: channels.append('userdatachange_%d' % (i)) if channels: conf = config.redis_config_map.get('mix') ip, port = conf[0], conf[1] subscribe.startSubScriber(ip, port, channels, _onSubMessage)
def _initialize(): return # 当前没有做数据缓存,无需数据变化通知 if gdata.serverType() != gdata.SRV_TYPE_UTIL: return channelcount = 16 channels = [] usids = gdata.serverTypeMap()[gdata.SRV_TYPE_UTIL] usids.sort() if len(usids) < channelcount: if usids[0] == gdata.serverId(): for x in xrange(channelcount): channels.append('userdatachange_%d' % (x)) else: if gdata.serverId() in usids: i = usids.index(gdata.serverId()) if i < channelcount: channels.append('userdatachange_%d' % (i)) if channels: conf = config.redis_config_map.get('mix') ip, port = conf[0], conf[1] subscribe.startSubScriber(ip, port, channels, _onSubMessage)
def initGame(self): from hall.entity import hallaccount self._account = hallaccount # 大厅的账户处理类 serverType = gdata.serverType() if serverType == gdata.SRV_TYPE_CENTER: centers = gdata.serverTypeMap().get(gdata.SRV_TYPE_CENTER, [])[:] centers.sort() sid = gdata.serverId() inits = gdata.centerServerLogics().get(sid, []) # 轮盘开奖信息的监听 from hall.servers.center.rpc.roulette_remote import sendReward globalEventBus.subscribe(EventHeartBeat, sendReward) if inits: for pkg in inits: ftlog.info('init center logic of ->', pkg) exec 'from %s import _initialize; _initialize(1)' % (pkg) if serverType == gdata.SRV_TYPE_UTIL: from hall.servers.util.account_handler import updateOnLineInfos globalEventBus.subscribe(EventHeartBeat, updateOnLineInfos) # 在线信息初始化, ONLIE处理必须在UTIL服务 from hall.entity import hallonline hallonline._initialize() if serverType == gdata.SRV_TYPE_TABLE or serverType == gdata.SRV_TYPE_ROOM: from hall.servers.room.room import reportRoomOnlineInfos globalEventBus.subscribe(EventHeartBeat, reportRoomOnlineInfos) from hall.entity import hallchatlog hallchatlog._initialize() # 注意: 各个模块间有先后初始化的顺序 from hall.entity import hallitem, hallstore, hallvip, hallbenefits, \ hallranking, hallshare, hallpromote, hallfree, hallgamelist, hallgamelist2, \ halldailycheckin, hallmenulist, hallcoupon, hallmoduletip, \ hallrename, hallads, hallflipcardluck, hallpopwnd, hallstartchip, \ fivestarrate, match360kp, neituiguang, hallstocklimit, \ hall_first_recharge, hallroulette, hallled, hall_exit_remind from hall.entity.hallactivity import activity from hall.entity.halltmpact import tmp_activity from hall.entity.hall_red_envelope import hall_red_envelope # 道具初始化 hallitem._initialize() # 限购初始化 hallstocklimit._initialize() # 商城初始化 hallstore._initialize() # VIP系统初始化 hallvip._initialize() # 救济金系统初始化 hallbenefits._initialize() # 用户初始基金初始化 hallstartchip._initialize() halldailycheckin._initialize() # 排行榜 hallranking._initialize(0) # 活动系统初始化 activity._initialize() hallcoupon._initialize() hallshare._initialize() hallgamelist._initialize() hallgamelist2._initialize() hallmenulist._initialize() hallrename._initialize() hallmoduletip._initialize() hallads._initialize() hallflipcardluck._initialize() hallpopwnd._initialize() hallpromote._initialize() hallfree._initialize() fivestarrate._initialize() match360kp._initialize() neituiguang._initialize() from hall.entity import halltask halltask.initialize() # 默认配置初始化 hallmoduledefault._initialize() halllocalnotification._initialize() # 首冲礼包配置 hall_first_recharge._initialize() tmp_activity._initialize() # 红包模块配置初始化 hall_red_envelope._initialize() # 钻石抽奖初始化 hallroulette._initialize() # led配置初始化 hallled._initializeConfig() # 退出提醒 hall_exit_remind._initialize() # 三方控制模块开关 hall_third_sdk_switch._initialize() # 域名配置初始化 halldomains._initialize() # 插件升级模块初始化 hall_game_update._initialize() # 登录奖励模块初始化 hall_login_reward._initialize() # 道具转换模块初始化 hall_item_exchange._initialize() # 自建桌房间号初始化 hall_friend_table._initialize() # 小推广系统初始化 from hall.entity import hall_simple_invite hall_simple_invite.initialize() # 房卡购买提示信息模块初始化 from hall.entity import hall_fangka_buy_info hall_fangka_buy_info._initialize()
def sendToAllCoServer(cls, mo): ''' 发送消息到所有TCP管理服务器''' msgpack = mo.pack() coSrvIds = gdata.serverTypeMap()[gdata.SRV_TYPE_CONN] for coSrvId in coSrvIds: wrapper.send(coSrvId, msgpack, "S1", "")
def initGame(self): from hall.entity import hallaccount self._account = hallaccount # 大厅的账户处理类 serverType = gdata.serverType() if serverType == gdata.SRV_TYPE_CENTER: centers = gdata.serverTypeMap().get(gdata.SRV_TYPE_CENTER, [])[:] centers.sort() sid = gdata.serverId() inits = gdata.centerServerLogics().get(sid, []) # 轮盘开奖信息的监听 from hall.servers.center.rpc.roulette_remote import sendReward globalEventBus.subscribe(EventHeartBeat, sendReward) if inits: for pkg in inits: ftlog.info('init center logic of ->', pkg) exec 'from %s import _initialize; _initialize(1)' % (pkg) if serverType == gdata.SRV_TYPE_UTIL: from hall.servers.util.account_handler import updateOnLineInfos globalEventBus.subscribe(EventHeartBeat, updateOnLineInfos) # 在线信息初始化, ONLIE处理必须在UTIL服务 from hall.entity import hallonline hallonline._initialize() if serverType == gdata.SRV_TYPE_TABLE or serverType == gdata.SRV_TYPE_ROOM: from hall.servers.room.room import reportRoomOnlineInfos globalEventBus.subscribe(EventHeartBeat, reportRoomOnlineInfos) from hall.entity import hallchatlog hallchatlog._initialize() # 注意: 各个模块间有先后初始化的顺序 from hall.entity import hallitem, hallstore, hallvip, hallbenefits, \ hallranking, hallshare, hallpromote, hallfree, hallgamelist, hallgamelist2, \ halldailycheckin, hallmenulist, hallcoupon, hallmoduletip, \ hallrename, hallads, hallflipcardluck, hallpopwnd, hallstartchip, \ fivestarrate, match360kp, neituiguang, hallstocklimit, \ hall_first_recharge, hallroulette, hallled, hall_exit_remind from hall.entity.hallactivity import activity from hall.entity.halltmpact import tmp_activity from hall.entity.hall_red_envelope import hall_red_envelope # 道具初始化 hallitem._initialize() # 限购初始化 hallstocklimit._initialize() # 商城初始化 hallstore._initialize() # VIP系统初始化 hallvip._initialize() # 救济金系统初始化 hallbenefits._initialize() # 用户初始基金初始化 hallstartchip._initialize() halldailycheckin._initialize() # 排行榜 hallranking._initialize(0) # 活动系统初始化 activity._initialize() hallcoupon._initialize() hallshare._initialize() hallgamelist._initialize() hallgamelist2._initialize() hallmenulist._initialize() hallrename._initialize() hallmoduletip._initialize() hallads._initialize() hallflipcardluck._initialize() hallpopwnd._initialize() hallpromote._initialize() hallfree._initialize() fivestarrate._initialize() match360kp._initialize() neituiguang._initialize() from hall.entity import halltask halltask.initialize() # 默认配置初始化 hallmoduledefault._initialize() halllocalnotification._initialize() # 首冲礼包配置 hall_first_recharge._initialize() tmp_activity._initialize() # 红包模块配置初始化 hall_red_envelope._initialize() # 钻石抽奖初始化 hallroulette._initialize() # led配置初始化 hallled._initializeConfig() # 退出提醒 hall_exit_remind._initialize() # 三方控制模块开关 hall_third_sdk_switch._initialize() # 域名配置初始化 halldomains._initialize() # 插件升级模块初始化 hall_game_update._initialize() # 登录奖励模块初始化 hall_login_reward._initialize() # 道具转换模块初始化 hall_item_exchange._initialize() # 自建桌房间号初始化 hall_friend_table._initialize() # 小推广系统初始化 from hall.entity import hall_simple_invite hall_simple_invite.initialize() # 房卡购买提示信息模块初始化 from hall.entity import hall_fangka_buy_info hall_fangka_buy_info._initialize()