Tool/RobotTest/AI/AIFile/AILoginout.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/AI/AIFile/AIOnlineReply.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/Configuration/Config.ini | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/ConfigurationReader/ConfigIniReader.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/Main.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/Robot/RobotBase.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Tool/RobotTest/framework/frame.py | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Tool/RobotTest/AI/AIFile/AILoginout.py
@@ -270,6 +270,8 @@ cAccessLogin.AppID = appID cAccessLogin.ServerID = int(sid[1:]) cAccessLogin.Adult = self.robot.GetRobotConfig()[3] cAccessLogin.ExtraLen = len(appID) cAccessLogin.Extra = appID self.robot.Send(cAccessLogin) #print "New Player Login ---------- ", self.robot.GetRobotConfig()[1] Tool/RobotTest/AI/AIFile/AIOnlineReply.py
@@ -11,25 +11,26 @@ import time #在线回复间隔(Second) OnlineReplyPeriod = 15 OnlineReplyPeriod = 30 class AIOnlineReply(AIBase): #所有AI必须采用这中固定的初始化原型,以便AIMgr自动加载 def __init__(self, robot ): AIBase.__init__(self, robot, OnlineReplyPeriod, True, True ) self.lastTime = 0 def _Process( self ): if time.time() - self.lastTime < OnlineReplyPeriod: return # 清除没有心跳包的机器人 logging.info("危险超过15秒没有处理心跳包-%s"%self.robot.GetPlayerInfo().GetAccID()) #self.robot.SetNeedDestroy(True) #from Robot import RobotMgr #RobotMgr.GetRobotMgr().DisconnectServer(self.robot) pass return #======================================================================= # if time.time() - self.lastTime < OnlineReplyPeriod: # return # # # 清除没有心跳包的机器人 # logging.info("clear no heart robot") # self.robot.SetIsLoginOK(False) # from Robot import RobotMgr # RobotMgr.GetRobotMgr().DisconnectServer(self.robot) # pass #======================================================================= def _RegisterPacket(self, aiMgr): #//01 13 服务器心跳包#tagServerHeart @@ -39,10 +40,8 @@ def OnHeart(self, pack): nowTime = time.time() onlineR = tagCOnlineReturn() self.robot.Send( onlineR ) self.lastTime = time.time() #print "------回复0113心跳包" Tool/RobotTest/Configuration/Config.ini
@@ -25,4 +25,9 @@ PlayerOffTime=10 ProcessFindTJGTime=10 ServerDBConfigPath=D:\ProjectServer\db\PyMongoDataServer StartRunTime=10 StartRunTime=10 ;账号获取来源 0:自动生成, 1:取库中已有账号 AccountSource = 1 ;登录玩家数量 MaxPlayerCnt = 300 Tool/RobotTest/ConfigurationReader/ConfigIniReader.py
@@ -61,7 +61,16 @@ self.ProcessFindTJGTime = config.GetIntValue( "ProcessFindTJGTime") self.ServerDBConfigPath = config.GetValue( "ServerDBConfigPath") self.StartRunTime = config.GetIntValue( "StartRunTime") self.AccountSource = config.GetIntValue( "AccountSource") self.MaxPlayerCnt = config.GetIntValue( "MaxPlayerCnt") def GetMaxPlayerCnt(self): return self.MaxPlayerCnt # 账号获取来源 0:自动生成, 1:取库中已有账号 def GetAccountSource(self): return self.AccountSource def GetIOThreadNum(self): return self.IOThreadNum Tool/RobotTest/Main.py
@@ -28,11 +28,11 @@ logname = sys.argv[1] if HaveDEBUG: #gc.set_debug(gc.DEBUG_LEAK) InitMyLog("InsideRobot%s"%logname, True, logging.DEBUG) InitMyLog("RobotTest%s"%logname, True, logging.DEBUG) else: #gc.set_debug(gc.DEBUG_LEAK) #gc.disable() InitMyLog("InsideRobot%s"%logname, True, logging.INFO) InitMyLog("RobotTest%s"%logname, True, logging.INFO) from framework.frame import StartApp Tool/RobotTest/Robot/RobotBase.py
@@ -371,7 +371,11 @@ self.allsend += sendPack.GetLength() logging.debug( "%s send %d bytes data. recvAll:%d sendAll:%d ALL:%d" % \ ( str(self), sendPack.GetLength(), self.allrecv, self.allsend, self.allrecv+self.allsend ) ) self.__mgr.SendData( self.__peer, sendPack.GetBuffer(), sendPack.GetLength() ) try: self.__mgr.SendData( self.__peer, sendPack.GetBuffer(), sendPack.GetLength() ) except: print self.__peer, sendPack.OutputString() ## py自定义包mapserver包 Tool/RobotTest/framework/frame.py
@@ -27,7 +27,7 @@ import traceback import base64 #import pymongo import pymongo import datetime @@ -83,50 +83,54 @@ self.PlayerOffTime = config.GetPlayerOffTime() #玩家下线时长 self.ServerDBConfigPath = config.GetServerDBConfigPath() #数据库路径 #self.InitDBCon() self.InitDBCon() self.tokenList = [] # 数据库获取,登录去除 self.maxPlayerCnt = 200 self.maxPlayerCnt = config.GetMaxPlayerCnt() self.loginCnt = 0 #=========================================================================== # def InitDBCon(self): # dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1) # dbConfig.SetSection( "auth" ) # self.user = dbConfig.GetValue("logdb_user") # self.pwd = GetEncodePsw(dbConfig.GetValue("logdb_pwd"))[1] # # dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2) # dbConfig2.SetSection( "connect" ) # self.dbIP = dbConfig2.GetValue("LOG_DB_IP") # self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False) # db = self.connection.admin # if not db.authenticate(self.user, self.pwd): # logging.error( "!!!InitDBCon error" ) # return # # #print dbConfig2.GetValue("LOG_DB_NAME"), "--------------" # # self.logdb = self.connection[dbConfig2.GetValue("LOG_DB_NAME")] # #self.interfaceDatadb = self.connection[dbConfig2.GetValue("INTERFACE_DB_NAME")] # self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")] # # logging.info("conn ok-----------") #=========================================================================== self.AccountSource = config.GetAccountSource() def InitDBCon(self): dbConfig = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath1) dbConfig.SetSection( "auth" ) self.user = dbConfig.GetValue("userdb_user") self.pwd = GetEncodePsw(dbConfig.GetValue("userdb_pwd"))[1] dbConfig2 = ConfigurationReader.ConfigIniReader.AppConfig(self.ServerDBConfigPath + ServerDBConfigPath2) dbConfig2.SetSection( "connect" ) self.dbIP = dbConfig2.GetValue("USER_DB_IP") self.connection = pymongo.Connection(self.dbIP, 27017, auto_start_request=False) db = self.connection.admin if not db.authenticate(self.user, self.pwd): logging.error( "!!!InitDBCon error" ) return self.userdb = self.connection[dbConfig2.GetValue("USER_DB_NAME")] logging.info("conn ok-----------") # 1.获取脱机挂玩家数据--GameLog def GetTJGRobot(self): index = 0 if len(sys.argv) == 2: index = sys.argv[1] clientMac = "abc" for i in xrange(self.maxPlayerCnt): accID = "ice%s_%s@yun@s1"%(index, i) account = ("123456789012345678901234567890ab", accID, clientMac, 1) if account not in self.tokenList: self.tokenList.append(account) if self.AccountSource == 0: index = 0 if len(sys.argv) == 2: index = sys.argv[1] clientMac = "abc" for i in xrange(self.maxPlayerCnt): accID = "ice%s_%s@yun@s1"%(index, i) account = ("123456789012345678901234567890ab", accID, clientMac, 1) if account not in self.tokenList: self.tokenList.append(account) else: col = self.userdb["tagDSAccount"] account = None for rec in col.find(limit=self.maxPlayerCnt): account = ("123456789012345678901234567890ab", str(rec['ACCID']), 'anc', 1) if account not in self.tokenList: self.tokenList.append(account) print account if self.tokenList: logging.info( "待登录的脱机挂玩家----:%s"%(len(self.tokenList))) #logging.debug( "待登录的脱机挂玩家----tokenList:%s"%(self.tokenList)) @@ -136,6 +140,11 @@ def GetTokenList(self): return self.tokenList def AddCrossRobotInfo(self, accID, IPList): account = ("123456789012345678901234567890ab", accID, "abc", 1, IPList) if account not in self.tokenList: self.tokenList.append(account) def RemoveToken(self, value): self.tokenList.remove(value)